問題一覧 > 通常問題

No.1017 Reiwa Sequence

レベル : / AI推定難易度 : 1575 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 124
作問者 : maspy / テスター : beet
お気に入りにしたユーザー ProblemId : 4044 / 自分の提出
問題文最終更新日: 2022-04-25 10:42:46
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 242 (順位表) の他の問題:

Problem Statement

There is a sequence $A = A_1,A_2,\ldots,A_N$ of length $N$ consisting of positive integers. You will construct a sequence $B = B_1,B_2,\ldots,B_N$ by performing the following operation for each $i\in\{1,2,\ldots,N\}$.

  • Choose $x_i\in \{-1,0,1\}$ and set $B_i = A_ix_i$.

Make sure that both of the following $2$ conditions hold.

  • The sequence $B$ is zero-sum. That is, $\sum_{i=1}^NB_i=0$ holds.
  • The sequence $B$ has a term that is not $0$.

Input

$N$
$A_1\ A_2\ \cdots\ A_N$

  • All input values are integers.
  • $1\leqq N\leqq 150000$
  • $1\leqq A_i\leqq 150000$

Output

If it is impossible to obtain a sequence satisfying the conditions through the operations, print No. If it is possible, print Yes on the $1$st line, and print the resulting sequence $B = B_1,B_2,\ldots,B_N$ separated by spaces on the $2$nd line.
Print a newline at the end.

Sample

Sample 1
Input
5
1 2 3 4 5
Output
Yes
1 -2 0 -4 5

Other sequences such as 0 -2 3 4 -5 and 0 2 3 0 -5 can also be obtained. Any sequence satisfying the conditions will be judged as correct. Note that 0 0 0 0 0 does not satisfy the conditions.

Sample 2
Input
3
2019 5 1
Output
No

Sample 3
Input
2
10 10
Output
Yes
10 -10

Sample 4
Input
9
314 159 265 358 979 323 846 264 338
Output
Yes
314 159 0 358 0 -323 -846 0 338

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