AtCoder Regular Contest 153
翻译中…
Problem Statement
翻译中…
You are given a sequence of length $N$, $A = (A_1, \ldots, A_N)$, consisting of $1$ and $-1$.
翻译中…
Determine whether there is an integer sequence $x = (x_1, \ldots, x_N)$ that satisfies all of the following conditions, and print one such sequence if it exists.
翻译中…
$|x_i| \leq 10^{12}$for every$i$($1\leq i\leq N$).$x$is strictly increasing. That is,$x_1 < \cdots < x_N$.$\sum_{i=1}^N A_ix_i = 0$.
翻译中…
Constraints
翻译中…
$1\leq N\leq 2\times 10^5$$A_i \in \lbrace 1, -1\rbrace$
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N
A_1 \ldots A_N
翻译中…
Output
翻译中…
If there is an integer sequence $x$ that satisfies all of the conditions in question, print Yes; otherwise, print No. In case of Yes, print the elements of such an integer sequence $x$ in the subsequent line, separated by spaces.
翻译中…
x_1 \ldots x_N
翻译中…
If multiple integer sequences satisfy the conditions, you may print any of them.
翻译中…
样例
Input #1
5
-1 1 -1 -1 1
Output #1
Yes
-3 -1 4 5 7
For this output, we have $\sum_{i=1}^NA_ix_i= -(-3) + (-1) - 4 - 5 + 7 = 0$.
Input #2
1
-1
Output #2
Yes
0
Input #3
2
1 -1
Output #3
No
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。