問題一覧 > 通常問題

No.2451 Redistribute Integers

レベル : / AI推定難易度 : 650 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 154
作問者 : srjywrdnprkt / テスター : 👑 p-adic
お気に入りにしたユーザー ProblemId : 9779 / 自分の提出
問題文最終更新日: 2025-02-04 10:40:42
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 403 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。