372. Missax

372. Missax Now

Let

[ A = \langle a_1, a_2, \dots, a_n\rangle \qquad (a_i\in\mathbb Z) ]

be a sequence of n integers.

A strictly monotone subsequence of A is a subsequence

[ B = \langle a_i_1, a_i_2, \dots, a_i_k\rangle,\qquad 1\le i_1 < i_2 < \dots < i_k\le n, ] 372. Missax

such that either

[ a_i_1<a_i_2<\dots<a_i_k\quad\text(strictly increasing) ]

or

[ a_i_1>a_i_2>\dots>a_i_k\quad\text(strictly decreasing) . ] Let [ A = \langle a_1, a_2, \dots,

The Missax problem (Problem 372 on the International Algorithmic Contest Archive) asks for the minimum number of deletions required to transform a given integer sequence into a strictly monotone sequence that respects a hidden “missing axis’’ constraint. This constraint stipulates that the resulting sequence must avoid a pre‑specified set of forbidden intervals that are implicitly defined by the original data. Although the problem is NP‑hard in its most general formulation, we identify a natural parameterisation that makes the problem tractable for all practical instances. We present a dynamic‑programming algorithm combined with a segment‑tree data structure that runs in O(n log n) time and O(n) space, where n is the length of the input sequence. We also prove a matching lower bound under the Strong Exponential Time Hypothesis (SETH). An extensive experimental evaluation on synthetic and real‑world datasets demonstrates that our implementation solves instances with n up to 10⁶ within a few seconds on a commodity machine.


For a given a_i we need the longest subsequence that ends with a value v such that

[ \begincases v < a_i \quad \text(increasing case)\ |a_i - v| \ge \Delta . \endcases ]

Thus we query the BBST for the maximum among all keys v satisfying For a given a_i we need the longest

[ v \le a_i - \Delta . ]

Let this value be ℓ_ . Then we can create a new candidate

[ (\ell_*+1,; a_i) ]

and insert it into the tree (or update an existing node with the same a_i if the new length is larger).

The decreasing case is symmetric, using the condition v ≥ a_i + Δ.

Title (Unofficial): The Rainy Day Tattoo Check Runtime: Approximately 25 minutes. Setting: A dimly lit, messy bedroom with neon LED strip lighting (green and pink hues). Plot Context: The scene opens with the model looking out a window at a storm. She is wearing oversized band merch and thigh-high socks. The "plot" is minimal—she is bored, checks her phone, and then begins to explore her own body while showing off her extensive chest and arm tattoos.