問題一覧 > 通常問題

No.1586 Equal Array

レベル : / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 300
作問者 : e869120 / テスター : PCTprobability
お気に入りにしたユーザー ProblemId : 6690 / 自分の提出
問題文最終更新日: 2021-07-08 21:59:04
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 303 (順位表) の他の問題:

Problem Statement

You are given a sequence $A=(A_1, A_2, \cdots, A_N)$ of length $N$.
Determine whether it is possible to make all elements of the sequence equal by performing the following operation some number of times.

  • Choose integers $i, j$ $(1 \leq i, j \leq N, i \neq j)$, then simultaneously increase $A_i$ by $1$ and decrease $A_j$ by $1$.

Input

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

Output

Print Yes if it is possible to make all elements of the sequence equal, and No otherwise.

Constraints

  • $2 \leq N \leq 100000$
  • $1 \leq A_i \leq 10^9$
  • All input values are integers.

Sample

Sample 1
Input
3
48 51 51
Output
Yes

Performing the operations as follows makes all elements of the sequence equal.

  • Operation 1: Choose $i = 1, j = 2$ and perform the operation. Then, $A = (49, 50, 51)$.
  • Operation 2: Choose $i = 1, j = 3$ and perform the operation. Then, $A = (50, 50, 50)$.

Sample 2
Input
7
80 90 65 65 80 50 65
Output
No

No matter how the operations are performed, it is impossible to make all elements of the sequence equal.

Sample 3
Input
3
219 219 219
Output
Yes

All elements of the sequence are already equal before any operation is performed.

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