Queue (周赛3)
来源:互联网 发布:linux 显卡驱动安装 编辑:程序博客网 时间:2024/06/06 02:25
Little girl Susie went shopping with her mom and she wondered how to improve service quality.
There are n people in the queue. For each person we know timeti needed to serve him. A person will be disappointed if the time he waits is more than the time needed to serve him. The time a person waits is the total time when all the people who stand in the queue in front of him are served. Susie thought that if we swap some people in the queue, then we can decrease the number of people who are disappointed.
Help Susie find out what is the maximum number of not disappointed people can be achieved by swapping people in the queue.
The first line contains integer n (1 ≤ n ≤ 105).
The next line contains n integersti (1 ≤ ti ≤ 109), separated by spaces.
Print a single number — the maximum number of not disappointed people in the queue.
515 2 1 5 3
4
Value 4 is achieved at such an arrangement, for example:1, 2, 3, 5, 15. Thus, you can make everything feel not disappointed except for the person with time 5.
为什么用C的快排就是超时,用C++的啥事儿没有,歧视有木有~ 表示很醉~ = =!
#include <stdio.h>#include <iostream>#include <algorithm>using namespace std;int a[100000];int main(){ int n,i; while(~scanf("%d",&n)) { long long count=0,sum=0; for(i=0;i<n;i++) { scanf("%d",&a[i]); } sort(a,a+n); //快排 for(i=0;i<n;i++) { if(a[i]>=sum) { count++; //累加 sum=sum+a[i]; //之前的时间累加 } } printf("%lld\n",count); } return 0;}
- Queue (周赛3)
- Queue(3)Queue的链式实现
- Queue 3
- iOS开发之GCD(3)Main Dispatch Queue/Global Dispatch Queue
- queue(3)--freebsd中的queue结构使用
- queue(3)--freebsd中的queue结构使用
- Team Queue 团体队列(queue运用)
- 周赛 POJ 3934 Queue
- 3:stack or queue
- Python多线程3:queue
- wait queue 3
- STL--queue(队列)
- (四):实战Queue
- work queue(1)
- 队列(Queue)
- 数据结构-队列(queue)
- UVA10128 - Queue(dp)
- C# 队列(Queue)
- 数字二进制表示中1的个数
- Andorid 如何监听app是否安装或卸载
- 数据测试读取和传输问题
- 数据存储结构
- manacher算法
- Queue (周赛3)
- HDU Train Problem II (卡特兰数+大数)
- 分享一款超好用的windows管理工具
- 同步与异步的区别
- jetty maven工程开启jetty调试
- vi编辑只读文档无法保存解决方法(转载)
- android 体系结构
- 正则表达式
- 图论500题