Блог пользователя Iam1789

Автор Iam1789, 4 месяца назад, По-английски

The answer is yes.There is a solution.You can read it from here(Chinese version) or read this English version below (translated by ERNIE Bot).

Below, $$$m$$$ means $$$b$$$.

First, we attempt to reduce the size of the range of $$$a_i$$$ (denoted as $$$[L_i, R_i]$$$) from $$$2^m$$$ to less than $$$2^{m-i}$$$, shaping the ranges into a staircase pattern. Assuming we have already determined the first $$$i-1$$$ terms and are trying to decide the $$$i$$$-th term. If $$$a_i < 2^{m-i}$$$, we proceed to the next term; otherwise, we enumerate from the $$$i-1$$$-th term towards the left. Suppose we have enumerated up to the $$$j$$$-th term, if $$$a_i \geq 2^{m-j}$$$, we can delete $$$a_j$$$ directly because $$$a_j < 2^{m-j} \leq a_i$$$, rendering $$$a_j$$$ unable to be the maximum in the sequence. Otherwise, we stop here. After removing the deleted terms, we form a new sequence where each number's range meets our requirement.

Next, with each number's range in this staircase form, we aim to revert it back to a flat shape where $$$a_i < 2^k$$$ (with $$$k < m$$$). We maintain two pointers, $$$l$$$ and $$$r$$$. If $$$a_l > R_r$$$, we delete $$$a_r$$$ immediately; otherwise, the maximum value of $$$a_l$$$ can only be as large as the maximum of $$$a_r$$$, prompting us to adjust the range of $$$a_l$$$. Through manual experimentation, we observe that all values with a maximum less than $$$2^k$$$ are deleted, leaving $$$a_i$$$ ranges all less than $$$2^k$$$.

Through these two operations, we transform the original problem into a smaller subproblem, which can be recursively solved. To analyze the number of operations, suppose we end up with $$$x$$$ numbers, each with a range size of $$$2^{m-x}$$$. During the staircase formation, we traverse from 1 to $$$n$$$, resulting in $$$n$$$ queries (referred to as Type 1 queries). The queries generated during the two-pointer process (Type 2 queries) and the queries from deleting elements during the flat-to-staircase transformation (Type 3 queries) do not exceed $$$n$$$ combined, as elements queried in Type 2 are deleted and cannot participate in Type 3. When transforming flat to staircase, if $$$a_i \geq 2^{m-i}$$$, a query is generated without deleting any elements (Type 4 queries), which occur at most $$$n$$$ times. Thus, $$$\text{T}(m,n) = \max_{x=1}^{\min(n-1,m)}\text{T}(m-x,x) + 3n$$$, and computational experiments reveal the total operation count does not exceed $$$3(n+m)$$$, meeting the given upper limit.

Considering a simple optimization: if the lower bound of the currently determined sequence's maximum ($$$\max_{i=1}^nL_i$$$) is not lower than a number's upper bound, we delete that number. Analyzing the query types: let $$$y_1, y_2, y_3, y_4$$$ represent the counts of Type 1, 2, 3, and 4 queries, respectively. Notice that if a Type 4 query is performed on the $$$i$$$-th number, its upper bound is the same as its left neighbor's. If this number is deleted through a Type 3 query, its left neighbor is also deleted, effectively "amortizing" the Type 4 query.

Assuming the number of elements transforms from $$$x_1$$$ to $$$x$$$ after the staircase-to-flat process. Among $$$y_2$$$ Type 2 queries, $$$x_1-x$$$ numbers are deleted, leaving $$$x$$$ numbers. If a number queried in Type 4 is deleted, its query can still be amortized into Type 2 queries as before. Thus, the unamortized Type 4 queries are at most $$$x$$$. Summing up, Type 1 queries remain $$$n$$$, Type 2 and 3 queries combined are still at most $$$n$$$, but genuine Type 4 queries contribute at most $$$x$$$ times, yielding $$$\text{T}(m,n) = \max_{x=1}^{\min(n-1,m)}\text{T}(m-x,x) + 2n + x$$$, and experiments show the total does not exceed $$$2n+3m$$$.

Submission record

If u have a better solution or any questions with my solution,you can feel free to contact with me.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +25
  • Проголосовать: не нравится