CodeForces 545D Queue (排序模拟)
2015-09-17 08:23
232 查看
【题目链接】:click here~~
【题目大意】:
有n个人,每个人都有一个等待时间,如果对于当前的人来说总等待时间超过自己的等待时间,那么这个人就会失望,问换一下顺序,使失望的人最少,问最多有多少个人不失望。
【思路】:排一下序然后加然后与当前的比较。如此。。
代码:
【题目大意】:
有n个人,每个人都有一个等待时间,如果对于当前的人来说总等待时间超过自己的等待时间,那么这个人就会失望,问换一下顺序,使失望的人最少,问最多有多少个人不失望。
【思路】:排一下序然后加然后与当前的比较。如此。。
代码:
/* * Problem: CodeForces 545D * Running time: 46MS * Complier: G++ * Author: herongwei * Create Time: 8:20 2015/9/17 星期四 */ #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> using namespace std; const int N=1e5+10; int arr ; int main() { int t;scanf("%d",&t); for(int i=1; i<=t; ++i) { scanf("%d",&arr[i]); } sort(arr+1,arr+1+t); int ans=1; int temp=arr[1]; for(int i=2; i<=t; ++i) { if(arr[i]>=temp) { ans++; temp+=arr[i]; } } printf("%d\n",ans); }
相关文章推荐
- CodeForces 545B Equidistant String (模拟)
- Android消息处理机制(Handler、Looper、MessageQueue与Message)
- UIView-4-EventForViews(在view上加入button时候的事件处理)
- cf#320 Div.2 Problem B Finding Team Member
- Leetcode #225 Implement Stack using Queues
- longest increasing continuous subsequence in a 2D matrix
- Solr 使用自定义 Query Parser
- solr 使用自定义的 QueryParser
- iOS UI基础-9.1 UITableView 团购
- Mac OS X中启动MySQL报错:ERROR! The server quit without updating PID file
- SPOJ Query on a tree (树链剖分)
- UIImage+ImageEffects的category 模糊效果
- iOS Dev (27) 初步了解下UIView的最常用知识
- ios上 更改 状态栏(UIStatusBar)的颜色,你值得一看、收藏
- this class is not key value coding-compliant for the key ... 报这个错误
- spark RDD keyvalue操作
- UIColor之【扩展:#FFFFFF ->UIColor】
- window.requestAnimationFrame 兼容性封装,调节重新渲染,提高网页性能
- 汇总各种Android 蓝牙各种UUID
- 为SQL Server创建Sequence