問題一覧 > 通常問題

No.2821 A[i] ← 2A[j] - A[i]

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 1.500秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 72
作問者 : みどりむし🦠 / テスター : achapi FplusFplusF viral8 👑 AngrySadEight
お気に入りにしたユーザー ProblemId : 10087 / 自分の提出
問題文最終更新日: 2024-07-26 19:35:13
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 438 (順位表) の他の問題:

Problem Statement

There are $N$ integers $A_1, A_2, \dots, A_N$.

Solve the following $N$ mutually independent problems $1\text{-gathering}, 2\text{-gathering}, \dots, N\text{-gathering}$:

$k\text{-gathering}$

There is an integer sequence $B = (B_1, B_2, \dots, B_k)$ of length $k$, and initially $B = (A_1, A_2, \dots, A_k)$ holds.

You may perform the following operation any number of times, possibly $0$ or more:

  • Freely choose $2$ integers $i, j$ such that $1 \leq i, j \leq k$, and replace $\large B_i$ with the value of $\large 2B_j - B_i$.

Find the minimum value $V'_k$ of $V_k \coloneqq \displaystyle \max B - \min B$ that can be obtained by performing the operations appropriately.
Note that this value always exists.

Input

The input is given from standard input in the following format:

$N$
$A_1 \enspace A_2 \enspace \dots \enspace A_N$

Output

Output the values of $V'_1, V'_2, \dots, V'_N$ to standard output in the following format:

$V'_1$
$V'_2$
$\vdots$
$V'_N$

Constraints

  • $1 \leq N \leq 3 \times 10^5$
  • $\left| A_i \right| < 2^{60} \scriptsize \; (1 \leq i \leq N)$
  • All input values are integers

Sample

Sample Input/Output 1
Input
4
2 6 5 -4
Output
0
4
1
1

For example, for the problem $3\text{-gathering}$, $V_3 = 1$ can be achieved by performing the operations as follows:

  • Initially, $B = (2, 6, 5)$.
  • Perform the operation with $(i, j) = (2, 3)$.
    • $B = (2, 4, 5)$ results.
  • Perform the operation with $(i, j) = (3, 2)$.
    • $B = (2, 4, 3)$ results.
  • Perform the operation with $(i, j) = (1, 3)$.
    • $B = (4, 4, 3)$ results.
    • At this point, $\max B - \min B = 4 - 3 = 1$.
Also, no matter how the operations are performed, $V_3 < 1$ cannot be achieved, so $V'_3 = 1$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。