UVA 11729简单贪心
来源:互联网 发布:js给a标签的href赋值 编辑:程序博客网 时间:2024/06/12 18:43
题意:你有n个部下,每个部下需要完成一项任务。第i个部下需要你花Bi分钟交代任务,然后他会立刻独立的执行Ji分钟后完成任务。你需要选择交待任务的顺序,使的所有任务尽早执行完毕(即最后执行完成的任务的结束时间应尽量早)。注意,不能同时给两个部下交代任务,但部下可以同时执行他们自己的任务;
思路:生活常识,执行时间长的任务应该尽早做;所以,先排个序吧;
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<map>#include<stack>#include<queue>#include<algorithm>#include<set>#include<vector>#include<cmath>#define lmid l,m,rt<<1#define rmid m+1,r,rt<<1|1#define LL long long#define rl r-l+1using namespace std;struct node{ int a,b; bool operator <(const node &x)const { return b>x.b; }}s[1005];int main(){ int n; int ca=1; while(scanf("%d",&n)==1) { if(n==0) break; for(int i=0;i<n;i++) { scanf("%d %d",&s[i].a,&s[i].b); } sort(s,s+n); int sum=0; int res=0; for(int i=0;i<n;i++) { sum+=s[i].a; res=max(sum+s[i].b,res); } printf("Case %d: ",ca++); cout<<res<<endl; } return 0;}
阅读全文
0 0
- UVA 11729简单贪心
- UVA - 10700 - Camel trading (简单贪心)
- UVA - 108 - Maximum Sum (简单贪心)
- UVA 1149 Bin Packing 装箱(简单贪心)
- Commando War UVa 11729(贪心)
- UVa 11729 Commando War (贪心)
- UVa 11729 Commando War / 贪心
- UVA 11729 - Commando War(贪心)
- UVa 11729 Commando War 贪心
- UVA - 11729 Commando War (贪心)
- UVA - 11729 Commando War (贪心)
- UVA 11729 COMMANDO WAR【贪心】
- uva 11729 贪心 + STL 应用
- UVa Commando War 11729 (贪心)
- UVa 11729 - Commando War(贪心)
- Uva 11729 Commando War【贪心】
- UVA 11729 Commando War(贪心)
- |UVA 11729|贪心|Commando War
- 关于ThreadLocal的使用心得
- 创建第一个程序
- Xml文件在unity中的读写-----模拟玩游戏时我们保存游戏的动作
- extern "C" __declspec(dllexport) __declspec(dllimport) 和 def
- 百度地图集成
- UVA 11729简单贪心
- jquery入门2
- Jzoj2756 Longge的问题
- 数据库表间关系
- 单例模式
- 关于Redis的相关知识个人总结
- 个人域名绑定git page,步骤详细,不懂联系本人企鹅446690578
- 聊天图形化界面
- Python自动化视频