HDU 4070 + 赤裸裸的贪心~~
J - Phage War
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Phage War is a little flash game. In this game, we want infect all cells by the transmission and breed of phages.
Originally, there is a cell infected by phages and this cell can breed a new phage every second. You should know that only the new born phages can inject other cells.

There are n cells around this cell, numbered from 1 to n. If there are Di phages reaching the i-th cell, the cell would be infected, and the phages journey will cost Ti seconds. To simplify it, we assume these phages will stay in this new cell and they can’t infect other cells. And the new cell cannot breed new phages and infect other cells.
Can you tell me how much time it costs to infect all cells at least?
Input
In each case, the first line contains a integers N (1 <= N <= 10^5). Then there are N lines, each line contain two integers Di, Ti (1<=Di, Ti<=100).
Output
Sample Input
2
2 1
5 6
2
1 11
3 10
Sample Output
Case 1: 11
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = ;
struct node{
int d,t;
};
bool cmp(const node& a,const node& b){
return a.t > b.t;
}
node bug[MAXN];
int main()
{
int t,n,cas = ;
cin>>t;
while(t--){
scanf("%d",&n);
for(int i = ;i <= n;i++)
scanf("%d%d",&bug[i].d,&bug[i].t);
sort(bug + ,bug + + n,cmp);
int ans = ,tmp,acum = ;
for(int i = ;i <= n;i++){
tmp = bug[i].d + bug[i].t + acum;
if(ans < tmp) ans = tmp;
acum += bug[i].d;
}
printf("Case %d: %d\n",cas++,ans);
}
return ;
}
HDU 4070 + 赤裸裸的贪心~~的更多相关文章
- HDU 4442 Physical Examination(贪心)
HDU 4442 Physical Examination(贪心) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=4442 Descripti ...
- hdu 4070 福州赛区网络赛J 贪心 ***
优先发路程最长的 #include<cstdio> #include<iostream> #include<algorithm> #include<cstri ...
- HDU 5835 Danganronpa (贪心)
Danganronpa 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5835 Description Chisa Yukizome works as ...
- HDU 5821 Ball (贪心)
Ball 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5821 Description ZZX has a sequence of boxes nu ...
- hdu 4004 (二分加贪心) 青蛙过河
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4004 题目意思是青蛙要过河,现在给你河的宽度,河中石头的个数(青蛙要从石头上跳过河,这些石头都是在垂 ...
- Saving HDU(hdu2111,贪心)
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- HDU 4714 Tree2cycle:贪心
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4714 题意: 给你一棵树,添加和删除一条边的代价都是1.问你将这棵树变成一个环的最小代价. 题解: 贪 ...
- HDU 5303 Delicious Apples (贪心 枚举 好题)
Delicious Apples Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Other ...
- HDU 5976 Detachment 【贪心】 (2016ACM/ICPC亚洲区大连站)
Detachment Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
随机推荐
- mycat——未完成
https://www.cnblogs.com/joylee/p/7513038.html https://blog.csdn.net/wrs120/article/details/80417345 ...
- N分之一 竖式除法模拟
N分之一 Description Alice越来越痴迷于数学问题了.一天,爸爸出了个数学题想难倒她,让她求1 / n. 可怜的Alice只有一岁零九个月,回答不上来 ~~~~(>_<)~~ ...
- Microsoft Azure 资料整理
鉴于Microsoft Azure的技术迭代更新相当快,所以推荐大家还是以官方文档为准. 以Global Azure 的为主,Mooncake版本自行删减 首先推荐Azure for MSDN htt ...
- Swift - 修改导航栏“返回”按钮文字,图标
Swift - 修改导航栏“返回”按钮文字,图标 2015-11-27 09:13发布:hangge浏览:4037 项目中常常会使用 UINavigationController 对各个页面进行导 ...
- Automation 的 ReportFlow
ReportFlow: // click the Grid icon and switch to grid page public void changeToGrid() // click the A ...
- [luoguP1013] 进制位(搜索)
传送门 纯搜索,无优化! #include <cstdio> #include <cstring> #include <iostream> #include < ...
- Codeforces Round #259 (Div. 2) D
D. Little Pony and Harmony Chest time limit per test 4 seconds memory limit per test 256 megabytes i ...
- 【BZOJ1758】重建计划(点分治)
题意: 给定一棵n个点的树,每条边有权值.求一条链,这条链包含的边数在L和U之间,且平均边权最大.N﹤=100000 思路:RYZ作业 二分答案再点分治,寻找是否有大于0且边数在L和U之间的链 f[i ...
- Linux下汇编语言学习笔记62 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- [bzoj1978][BeiJing2010]取数游戏 game_动态规划_质因数分解
取数游戏 game bzoj-1978 BeiJing-2010 题目大意:给定一个$n$个数的$a$序列,要求取出$k$个数.假设目前取出的数是$a_j$,那么下次取出的$a_k$必须保证:$j&l ...