codeforces-1201 B Zero Array

 1 #include <bits/stdc++.h>
 2 #define _for(i,a,b) for(int i = (a);i < b;i ++)
 3 typedef long long ll;
 4 using namespace std;
 5 inline ll read()
 6 {
 7     ll ans = 0;
 8     char ch = getchar(), last = ' ';
 9     while(!isdigit(ch)) last = ch, ch = getchar();
10     while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
11     if(last == '-') ans = -ans;
12     return ans;
13 }
14 inline void write(ll x)
15 {
16     if(x < 0) x = -x, putchar('-');
17     if(x >= 10) write(x / 10);
18     putchar(x % 10 + '0');
19 }
20 int n; 
21 int a[100003];
22 int main()
23 {
24     n = read();
25     _for(i,0,n)
26         a[i] = read();
27     
28     sort(a,a+n);
29     bool flag = true;
30     ll rnt2 = 0;
31     _for(i,0,n)
32         rnt2 += a[i];
33     if(rnt2&0x1 || a[n-1]*2>rnt2)
34         flag = false;
35     
36     if(flag)
37         printf("YES");
38     else
39         printf("NO");
40     return 0;
41 }

数学题,总和为偶数且最大的数不到总和的一半就输出YES

posted @ 2019-08-05 10:13  Asurudo  阅读(322)  评论(0编辑  收藏  举报