UVa 11729.Commando War【贪心】【10月6】
来源:互联网 发布:2015最好的网络机顶盒 编辑:程序博客网 时间:2024/06/16 12:47
Commando Wa
n个部下,布置任务需要b分钟,完成任务需要j分钟,如何布置最短时间全部完成。从完成任务需要世间最长的开始布置,贪心。代码:
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespace std;struct task{ int ttime,dotime;};bool cmp(task a,task b){ return a.dotime>b.dotime;}int main(){ int N,kase=1; while(scanf("%d",&N)==1&&N){ task man[1005]; for(int i=0;i<N;i++) scanf("%d%d",&man[i].ttime,&man[i].dotime); sort(man,man+N,cmp); int ans=0,talktime=0; for(int i=0;i<N;i++){ talktime+=man[i].ttime;//布置任务所需时间 ans=max(ans,talktime+man[i].dotime);//完成任务所需时间 } printf("Case %d: %d\n",kase++,ans); } return 0;}
0 0
- UVa 11729.Commando War【贪心】【10月6】
- Commando War-uva 贪心
- 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 Commando War 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 贪心的思想
- TextView.setText使用错误
- 养成记录的习惯
- linux常用网络命令
- 大素数判断和素因子分解(miller-rabin,Pollard_rho算法)
- 【ios编程报错处理-1】错误提示:App transport security has blocked a exceptions can be configured via your app's
- UVa 11729.Commando War【贪心】【10月6】
- java.lang.ClassCastException:java.lang.ClassCastException: android.view.AbsSavedState$1..解决方法
- 红黑树的插入删除完整版以及java版本
- python中%r和%s的区别
- VM-ware 虚拟机不能全屏解决方法
- pkg: /data/local/tmp/com.imooc.systeminfo Failure [INSTALL_FAILED_OLDER_SDK]
- 建立能与访问者相互通信的本地服务
- java中对集合或数组进行排序有两种方法:Comparable 与 Comparator
- Kth Smallest Element in a BST