Codeforces Round #248 (Div. 2) A. Kitahara Haruki's Gift

来源:互联网 发布:王侯将相宁有种乎读音 编辑:程序博客网 时间:2024/05/29 12:04
 

A. Kitahara Haruki's Gift

time limit per test
 1 second
memory limit per test
 256 megabytes
input
 standard input
output
 standard output

Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.

Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore the total weight of the apples given to Touma Kazusa must be equal to the total weight of the apples given to Ogiso Setsuna.

But unfortunately Kitahara Haruki doesn't have a knife right now, so he cannot split any apple into some parts. Please, tell him: is it possible to divide all the apples in a fair way between his friends?

Input

The first line contains an integer n (1 ≤ n ≤ 100) — the number of apples. The second line contains n integers w1, w2, ..., wn (wi = 100or wi = 200), where wi is the weight of the i-th apple.

Output

In a single line print "YES" (without the quotes) if it is possible to divide all the apples between his friends. Otherwise print "NO" (without the quotes).

Sample test(s)
input
3100 200 100
output
YES
input
4100 100 100 200
output
NO
Note

In the first test sample Kitahara Haruki can give the first and the last apple to Ogiso Setsuna and the middle apple to Touma Kazusa.


解题说明:此题的意思是平分一组数,由于只有100和200两个数值,简单判断就会发现首先100出现次数为奇数,或者100未出现200出现奇数次的情况下都不符合要求,其余情况均能够实现均分。

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. #include<iostream>  
  2. #include<cstdio>  
  3. #include<cmath>  
  4. #include<cstdlib>  
  5. #include <algorithm>  
  6. #include<cstring>  
  7. #include<string>  
  8. using namespace std;  
  9.   
  10. int main()  
  11. {  
  12.     int n, a = 0;  
  13.     int i, w;  
  14.     scanf("%d", &n);  
  15.     for (i = 0; i<n; i++)  
  16.     {  
  17.         scanf("%d", &w);  
  18.         if (w == 100)  
  19.         {  
  20.             a++;  
  21.         }  
  22.     }  
  23.     if (a % 2 == 1 || (n % 2 == 1 && a == 0))  
  24.     {  
  25.         printf("NO\n");  
  26.     }  
  27.     else  
  28.     {  
  29.         printf("YES\n");  
  30.     }  
  31.     return 0;  
  32. }  
0 0