No.2451 Redistribute Integers
タグ : / 解いたユーザー数 154
作問者 :
srjywrdnprkt
/ テスター :
👑 Problem Statement
You are given an integer sequence $A=(A_1, \cdots, A_N)$ of length $N$. Determine whether it is possible to make all elements of $A$ equal by performing the following operation $0$ or more times.
(Operation)
Choose an integer $i$ satisfying $1\leq i \leq N$ and subtract $N-1$ from $A_i$. Then, add $1$ to every element of $A$ other than $A_i$.
Input
$N$ $A_1$ $\cdots$ $A_N$
All inputs are integers and satisfy the following constraints.
- $2\leq N \leq 5\times 10^5$
- $-10^9 \leq A_i \leq 10^9$
Output
If it is possible to make all elements of $A$ equal by performing the operation $0$ or more times, print Yes; otherwise, print No.
Print a newline at the end.
Sample
Sample 1
Input
3 1 4 7
Output
Yes
Perform the operation with $i = 3, 3, 2$ in this order. Then, $A$ changes as $(1, 4, 7)\to(2,5,5)\to(3,6,3)\to(4,4,4)$.
In the end, all elements of $A$ can be made equal to $4$, so print Yes.
Sample 2
Input
6 1 2 3 4 5 6
Output
No
No matter how many times the operation is performed, it is impossible to make all elements equal.
Sample 3
Input
4 2 -6 -10 14
Output
Yes
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。