HDU 4221 Greedy?
来源:互联网 发布:中国威客网络兼职网 编辑:程序博客网 时间:2024/06/06 01:32
贪心,按照截止时间排序,输出时候长整型应该用%I64d.
#include <iostream>#include <algorithm>#include <cstdio>#include <memory.h>using namespace std;const int maxn=100010;struct Job{int C,D;bool operator<(const Job &rhs)const{return D<rhs.D;}}jobs[maxn];int n;int main(){int t,cas=1;scanf("%d",&t);while (t--){scanf("%d",&n);for (int i=0;i<n;++i){scanf("%d%d",&jobs[i].C,&jobs[i].D);}sort(jobs,jobs+n);long long curT=0,ans=0;for (int i=0;i<n;++i){curT+=jobs[i].C;if(curT-jobs[i].D>ans){ans=curT-jobs[i].D;}}printf("Case %d: %I64d\n",cas++,ans);}}
- 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
- windows 7打开telnet功能
- 已知rand7(),求rand10().
- 说说对javaee中的session的理解,你是怎么用session的?
- linux的system () 函数详解
- C++用new和不用new创建类对象区别
- HDU 4221 Greedy?
- jQuery.Autocomplete实现自动完成功能(详解)
- phpcms美化你的内容页--让侧边列表根据内容长度显示器
- 按位与,或,异或运算方法
- HTTP协议与HTML表单(再谈GET与POST的区别)
- metasploit编写自己的扫描器
- XML Configuration Access Protocol (XCAP)
- linux网络协议栈分析笔记5-IP层的处理1
- 题目1090:路径打印。N叉树