hdu 4221 Greedy?
来源:互联网 发布:知乎异性喜欢香水 编辑:程序博客网 时间:2024/06/05 07:26
题目链接:
点击打开链接
贪心水题, “he wants the maximum penalty of all the tasks to be as small as possible. ”指的是所有任务中最大的罚时数。
代码:
#include <iostream>#include <cstdio>#include <algorithm>using namespace std;struct node{ int a,b;};node N[100005];bool cmp(node x,node y){ return x.b<y.b;}int main(){ int T; int flag=1; int n; cin>>T; while(T--){ cin>>n; for(int i=1;i<=n;i++){ scanf("%d%d",&N[i].a,&N[i].b); } long long res=0; long long cur=0; sort(N+1,N+n+1,cmp); for(int i=1;i<=n;i++){ cur+=N[i].a; if(cur>=N[i].b) res=max(res,cur-N[i].b); } printf("Case %d: %I64d\n",flag++,res); } return 0;}
0 0
- hdu 4221Greedy?
- HDU 4221 Greedy?
- hdu 4221 Greedy?
- HDU 4221 Greedy?
- 贪心--HDU - 4221 Greedy?
- hdu Greedy 4221 (贪心)
- HDU 4221 Greedy?
- HDU 4221 Greedy?(贪心)
- HDU--4221--Greedy?
- HDU 4221 Greedy?(贪心)
- HDU 4221 Greedy?(DP)
- hdu 4221 Greedy 贪心算法
- HDU 4221 Greedy?(贪心)
- Greedy? HDU
- 4221 Greedy?
- hdu 1338 #greedy
- HDU 4380 - Farmer Greedy
- hdu 1009--greedy
- MinGW的安装及配置
- UILabel和UIButton的属性
- LeetCode | Roman to Integer(罗马数字转换成整数)
- 从头开始写项目Makefile(二):隐含规则自动推导
- 水题先来一道,UVA6345
- hdu 4221 Greedy?
- 设计模式之策略模式
- ubuntu 下安装jdk
- Java 关键字 this super 使用总结
- JAVA之数据库JDBC学习心得
- c c++ 画点 画线
- uva1378 - A Funny Stone Game SG函数
- What is a good text editor on Linux?
- Apache Camel简介