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 ...
随机推荐
- luogu 4884 多少个1?
题目描述: 给定整数K和质数m,求最小的正整数N,使得 11111⋯1(N个1)≡K(mod m) 说人话:就是 111...1111 mod m =K 题解: 将两边一起*9+1,左边就是10^an ...
- SpringBoot中部署Swagger2和Swagger-UI
1 Gradle配置在dependencies中添加以下依赖: implementation("io.springfox:springfox-swagger2:2.7.0") im ...
- atom 安装插件列表
插件列表 atom-beautify docblockr autocomplete-python goto-definition platformio-ide-terminal symbols-tre ...
- Python面试快问快答,理论要的就是速度与精准,Python面试题No2
今天的面试题 第1题:python2和python3的range(100)的区别 range()函数的含义 range函数是一个用来创建算数级数序列的通用函数,返回一个[start, start + ...
- Spring 和 Hibernate的整合
问题 ,spring 和 hibernate 整合 如何整合 1. Spring 使用Hibernate的的SessionFactory 2. Hibernate使用Spring提供的声明式事务
- org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start()
http://freestyle21.cn 不知什么时候,启动eclipse的时候就一直不行,说是an error ..我查了下log 报错:org.osgi.framework.BundleExce ...
- Linux下汇编语言学习笔记25 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- BNU2017校赛
A(模拟) 题意:求一个特殊图的最大流 分析:画画图发现就是for循环扫一遍 B(LCA) 题意:有n个点组成的树,有q个询问,每个询问(A,B,C),学生从B点走最短路径走到C点,再从C点走到根节点 ...
- Linux 网络配置,ifconfig不显示ip地址的解决办法
进入到/etc/sysconfig/network-scripts 然后设置虚拟机的网络配置 这样就配置成功了
- Why It is so hard to explain or show some thing
Why it is hard to explain something or learn something? For example, when I first know the hadoop, I ...