题目链接:http://codeforces.com/problemset/problem/160/A

注意排序是从大到小排,不要上来就sort导致从小到大排,细节水题。

AC代码:

#include <iostream>
#include <cstdio>
#include <algorithm> using namespace std; int arr[101];
int n; bool cmp(int a,int b) {
return a > b;
}
int main() {
while(scanf("%d",&n) != EOF && (n>=1 && n <= 100)) {
int sum = 0;
for(int i = 0;i < n;i++) {
scanf("%d",&arr[i]);
sum += arr[i];
}
int temp = 0;
int flag = 0;
sort(arr,arr+n,cmp);
for(int i = 0;i < n;i++) {
temp += arr[i];
sum -= arr[i];
flag++;
if(temp > sum)
break;
}
printf("%d\n",flag);
}
return 0;
}

[CodeForces 160A] Twins的更多相关文章

  1. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  2. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  3. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  4. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  5. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  6. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  7. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  8. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

  9. CodeForces - 148D Bag of mice

    http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...

随机推荐

  1. Win10系统,Jmeter 字体调整方法

    找到jmeter所在目录--->bin--->jmeter.properties, 1.搜索jsyntaxtextarea.font.size,去掉#,把14改成更大的数字 2.修改右侧参 ...

  2. Python3 Selenium自动化web测试 ==>FAQ:日期格式和日期字符串格式相互转换

    学习目的: 掌握python的基础应用 场景: 生成的测试日报需要加上时间戳作为唯一标志,免得文件覆盖,过往的文件丢失 因为os.rename方法要求文件名必须拼接的都是字符串 代码释义: # 日期转 ...

  3. Oracle拼接同一个字段多行的值

    本文引用自-   https://www.cnblogs.com/qianyuliang/p/6649983.html https://blog.csdn.net/defonds/article/de ...

  4. BootStrap Table方法使用小结

    参考链接:https://www.cnblogs.com/Amaris-Lin/p/7797920.html

  5. MemCache可视化客户端管理及监控工具TreeNMS

    参考地址:https://www.cnblogs.com/li150dan/p/9529054.html

  6. C# lambda查询带返回值

    问题来源: <深入理解C#(第3版)> 11页 具体如下: var lists=new List<string>{"111","222" ...

  7. 0《STL源码剖析》简介

    STL源码剖析 ----侯捷 STL主要包括六个组件: 1.配置器:负责空间配置和管理. 2.迭代器:扮演容器和算法之前的胶合剂,所谓“泛型指针”. 3.容器:各种数据结构,如vector,list, ...

  8. Jquery对表单、表格的操作以及应用

    表单的应用 (1)表单标签:包含处理表单数据所用的服务器端程序URL以及数据提交到服务器的方法 (2)表单域:包含文本框.密码框.隐藏域.多行文本框.复选框.单选框.下拉选择框.和文件上传框 (3)表 ...

  9. Design Compressed String Iterator

    Design and implement a data structure for a compressed string iterator. It should support the follow ...

  10. [转帖]密钥库文件格式(Keystore)和证书文件格式(Certificate)

    密钥库文件格式[keystore]代码 https://blog.csdn.net/zzhongcy/article/details/22755317 格式 : JKS 扩展名 : .jks/.ks ...