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 the first line there is an integer T (T <= 50), indicates the number of test cases. 
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

For each case, output the least time needed in one line.(as shown in the sample output)

Sample Input

2
2
2 1
5 6
2
1 11
3 10

Sample Output

Case 1: 11

Case 2: 14
 
  这是一道赤裸裸的贪心,,,不知为何,今天的思维非常的差感觉都没什么状态,,和队友讨论了很久这道题,起初我们的贪心的想法几乎完全不同,由于还没有和队友培养好默契,从而没有办法很好地在方向上得到一个统一,不过最终还是被队友AC了,成功地防止了我们爆零的节奏,,,,以此反省自己,作为队长一定要好好兼顾好每个人的想法。。。
 #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 + 赤裸裸的贪心~~的更多相关文章

  1. HDU 4442 Physical Examination(贪心)

    HDU 4442 Physical Examination(贪心) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=4442 Descripti ...

  2. hdu 4070 福州赛区网络赛J 贪心 ***

    优先发路程最长的 #include<cstdio> #include<iostream> #include<algorithm> #include<cstri ...

  3. HDU 5835 Danganronpa (贪心)

    Danganronpa 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5835 Description Chisa Yukizome works as ...

  4. HDU 5821 Ball (贪心)

    Ball 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5821 Description ZZX has a sequence of boxes nu ...

  5. hdu 4004 (二分加贪心) 青蛙过河

    题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4004 题目意思是青蛙要过河,现在给你河的宽度,河中石头的个数(青蛙要从石头上跳过河,这些石头都是在垂 ...

  6. Saving HDU(hdu2111,贪心)

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. HDU 4714 Tree2cycle:贪心

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4714 题意: 给你一棵树,添加和删除一条边的代价都是1.问你将这棵树变成一个环的最小代价. 题解: 贪 ...

  8. HDU 5303 Delicious Apples (贪心 枚举 好题)

    Delicious Apples Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Other ...

  9. HDU 5976 Detachment 【贪心】 (2016ACM/ICPC亚洲区大连站)

    Detachment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

随机推荐

  1. CentOS7-Git安装以及使用

    2018-09-14 Git安装 在bash终端中输入命令sudo yum install git回车. (出乎意料的顺利) 在随后出现的交互式对话中输入y即可. 随后,当任务执行完后,在bash中键 ...

  2. 笔试算法题(37):二叉树的层序遍历 & 最长递增的数字串

    出题:要求层序遍历二叉树,从上到下的层次,每一层访问顺序为从左到右,并将节点一次编号,输出如下:如果只要求打印指定的level的节点,应该如何实现. a b  c d  e  f  g h  i  分 ...

  3. ERC20 Token

    pragma solidity ^0.4.8; contract Token{ // token总量,默认会为public变量生成一个getter函数接口,名称为totalSupply(). uint ...

  4. 74-A/D指标,Accumulation/Distribution,积累/派发线,离散指标.(2015.7.1)

    A/D指标,Accumulation/Distribution 积累/派发线,离散指标 观井映天 2015.7.1

  5. swift -从相册中选择照片并上传

    选择本地图片并上传是应用开发中一个比较常见的功能.        原文出自:www.hangge.com  转载请保留原文链接:http://www.hangge.com/blog/cache/det ...

  6. js获取指定字符前/后的字符串简单实例

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  7. Excel表格如何设置密码 Excel2003/2007/2010设置密码教程

    http://www.wordlm.com/special/2/ 经常使用Excel表格制作报表和一些数据后,我们会给Excel表格设置密码,这样可以很有效的防止数据被盗取.目前Office版本众多, ...

  8. hihoCoder#1048 状态压缩·二

    原题地址 位运算的状态压缩太操蛋了,很容易出错...又是数组没开够导致诡异现象(明明某个值是1,莫名其妙就变成0了),害我debug一整天!fuck 代码: #include <iostream ...

  9. 概率dp呜呜

    概率dp有环怎么办? 答案可劲迭代 ,然后可劲消元 , 怎么消? 我就不知道了. 呵呵

  10. 【IntelliJ 】IntelliJ IDEA 自动导入包 快捷方式 关闭重复代码提示

    idea可以自动优化导入包,但是有多个同名的类调用不同的包,必须自己手动Alt+Enter设置 设置idea导入包 勾选标注 1 选项,IntelliJ IDEA 将在我们书写代码的时候自动帮我们优化 ...