CF1201B.Zero Array

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array a1,a2,…,ana_1, a_2, \ldots, a_n.

In one operation you can choose two elements aia_i and aja_j (i≠ji \ne j) and decrease each of them by one.

You need to check whether it is possible to make all the elements equal to zero or not.

给你一个数组 a1,a2,…,ana_1, a_2, \ldots, a_n。

在一次操作中,你可以选择两个元素 aia_i 和 aja_j(其中 i≠ji \ne j),并将它们各自减 11。

你需要判断是否可以通过若干次操作使所有元素都变为 00。

输入格式

The first line contains a single integer nn (2≤n≤1052 \le n \le 10^5) — the size of the array.

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \le a_i \le 10^9) — the elements of the array.

第一行包含一个整数 nn(2≤n≤1052 \le n \le 10^5)—— 数组的大小。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \le a_i \le 10^9)—— 数组的元素。

输出格式

Print "YES" if it is possible to make all elements zero, otherwise print "NO".

如果可以将所有元素变为零,则输出 "YES",否则输出 "NO"。

输入输出样例

  • 输入#1

    4
    1 1 2 2

    输出#1

    YES
  • 输入#2

    6
    1 2 3 4 5 6

    输出#2

    NO

说明/提示

In the first example, you can make all elements equal to zero in 33 operations:

  • Decrease a1a_1 and a2a_2,
  • Decrease a3a_3 and a4a_4,
  • Decrease a3a_3 and a4a_4

In the second example, one can show that it is impossible to make all elements equal to zero.

在第一个例子中,你可以通过 33 次操作使所有元素都变为零:

  • 减小 a1a_1 和 a2a_2,
  • 减小 a3a_3 和 a4a_4,
  • 减小 a3a_3 和 a4a_4

在第二个例子中,可以证明无法使所有元素都变为零。

输入解题思路,AI测评打分。不知道怎么写?

首页