CF1201B.Zero Array
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a1,a2,…,an.
In one operation you can choose two elements ai and aj (i=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,…,an。
在一次操作中,你可以选择两个元素 ai 和 aj(其中 i=j),并将它们各自减 1。
你需要判断是否可以通过若干次操作使所有元素都变为 0。
输入格式
The first line contains a single integer n (2≤n≤105) — the size of the array.
The second line contains n integers a1,a2,…,an (1≤ai≤109) — the elements of the array.
第一行包含一个整数 n(2≤n≤105)—— 数组的大小。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109)—— 数组的元素。
输出格式
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 3 operations:
- Decrease a1 and a2,
- Decrease a3 and a4,
- Decrease a3 and a4
In the second example, one can show that it is impossible to make all elements equal to zero.
在第一个例子中,你可以通过 3 次操作使所有元素都变为零:
- 减小 a1 和 a2,
- 减小 a3 和 a4,
- 减小 a3 和 a4
在第二个例子中,可以证明无法使所有元素都变为零。
输入解题思路,AI测评打分。不知道怎么写?