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

 

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
3
100 200 100
output
YES
input
4
100 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出现奇数次的情况下都不符合要求,其余情况均能够实现均分。

  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. }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值