CF#248DIV2:A.KitaharaHaruki'sGift_html/css_WEB-ITnose
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CF#248DIV2:A.KitaharaHaruki'sGift_html/css_WEB-ITnose,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2080字,纯文字阅读大概需要3分钟。
内容图文
![CF#248DIV2:A.KitaharaHaruki](/upload/InfoBanner/zyjiaocheng/399/bf1f75420216404492e8943d75b801df.jpg)
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.
好久没做CF了,这次又是打了个酱油
#include#include #include #include using namespace std;int a[105];int main(){ int n,i,sum1,sum2,sum; while(~scanf("%d",&n)) { sum1 = sum2 = sum = 0; for(i = 0; i<n; i++) { scanf("%d",&a[i]); sum+=a[i]; if(a[i] == 100) sum1++; else sum2++; } if(n == 1) { printf("NO\n"); continue; } sort(a,a+n); sum/=2; if(sum%100!=0 || sum1%2) printf("NO\n"); else { if(sum2%2 && sum1==0) printf("NO\n"); else printf("YES\n"); } } return 0;}
内容总结
以上是互联网集市为您收集整理的CF#248DIV2:A.KitaharaHaruki'sGift_html/css_WEB-ITnose全部内容,希望文章能够帮你解决CF#248DIV2:A.KitaharaHaruki'sGift_html/css_WEB-ITnose所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。