公式

C - ± Increasing Sequence 解説 by evima


Hints → https://atcoder.jp/contests/arc153/editorial/5524


[1] Translating the problem by a change of variables

For an integer sequence \(x = (x_1, \ldots, x_N)\), let an integer sequence \(y = (y_1, \ldots, y_N)\) defined as follows:

\[y_i = \begin{cases}x_1 & (i = 1)\\ x_i-x_{i-1} & (i\geq 2)\end{cases}\]

Here we have \(x_i = \sum_{k=1}^i y_k\), so one can restore \(x\) from \(y\). Thus, instead of finding \(x\), let us find \(y\). We have:

\[\sum_{i=1}^N \biggl(A_i\sum_{k=1}^{i}y_k\biggr) = \sum_{1\leq k\leq i\leq N}A_iy_k = \sum_{k=1}^N\biggl(\sum_{i=k}^NA_i\biggr)y_k.\]

If we let \(B_k = \sum_{i=k}^NA_i\), we have the following conditions on \(y\).

[Condition 1] \(\bigl\lvert \sum_{k=1}^i y_k\bigr\rvert \leq 10^{12}\) for \(1\leq i\leq N\).
[Condition 2] \(y_i > 0\) for \(2\leq i\leq N\).
[Condition 3] \(\sum_{i=1}^N B_iy_i = 0\).

Here, the condition that \(x\) must be strictly increasing has turned into independent conditions on individual terms, which is easier to handle.

Note that there is no restriction on \(y_1\) in [Condition 2].


[2] The case \(B_1\neq 0\)

Here, one can construct a solution as follows:

\[ y_i = \begin{cases} |B_1| & (i\geq 2) \\ -\frac{\sum_{i=2}^N B_i|B_1|}{B_1} & (i = 1)\end{cases}\]

Let us verify that this \(y\) satisfies the conditions. [Condition 2] and [Condition 3] are clearly satisfied. For [Condition 1], from \(|B_i|\leq N\), \(|y_i| \leq N\) for \(i\geq 2\), and \(|y_i|\leq (N-1)N\) for \(i=1\), so we have \(\sum_{i=1}^N|y_i| \leq 2N^2 \leq 10^{12}\).


[3] The case \(B_1 = 0\)

[3 - 1] If \(B_i \geq 0\) for every \(i\)

From \(|B_2 - B_1| = 1\) and so on, we have \(B_2 > 0\). Thus, under [Condition 2], we have:

\[\sum_{i=1}^N B_iy_i = \sum_{i=2}^NB_iy_i > 0.\]

Thus, there is no solution.

[3 - 2] If \(B_i \leq 0\) for every \(i\)

Similarly to [3 - 1], there is again no solution.

[3 - 3] The remaining case

From \(|B_i - B_{i+1}| = 1\), there are \(p, q\geq 2\) such that \(B_p = -1, B_q = 1\).

Let \(X = \sum_{i=2}^N B_i\). If \(X \geq 0\), let:

\[y_i = \begin{cases}1 & (i\neq p)\\ 1 + X & (i = p)\end{cases}\]

and if \(X< 0\), let:

\[y_i = \begin{cases}1 & (i\neq q)\\ 1 - X & (i = q)\end{cases}\]

Then, one can verify that the conditions are satisfied. The satisfaction of [Condition 1] can be shown using \(|X| \leq N^2 - N\) from \(|B_i|\leq N\).

投稿日時:
最終更新: