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. 题解 P1967 货车运输

    题目描述 A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路.每一条道路对车辆都有重量限制,简称限重.现在有 q 辆货车在运输货物,司机们想知道每辆车在不超过车辆限重的情况下,最多能 ...

  2. CentOS7 export命令

    一.windows下的环境变量 在windows系统下,很多软件安装都需要配置环境变量,比如安装jdk,假如你没有配置环境变量,那么在非软件安装的目录下使用javac命令,系统将会报这不是系统内部命令 ...

  3. assert.notDeepStrictEqual()详解

    assert.notDeepStrictEqual(actual, expected[, message]) 深度地严格不相等比较测试,与 assert.deepStrictEqual() 相反. c ...

  4. 集训第六周 数学概念与方法 概率 N题

    N - 概率 Time Limit:4000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status ...

  5. Swagger UI教程

    文档源地址 http://www.68idc.cn/help/makewebs/qitaasks/20160621620667.html Swagger-UI本身只提供在线测试功能,要集成它还需要告诉 ...

  6. Thinkphp5.0 视图view取值

    Thinkphp5.0 视图view取值 <!-- 获取控制器传递的变量 --> <li>{$age}</li> <!-- 获取服务器的信息 --> & ...

  7. Uvalive - 3026 Period (kmp求字符串的最小循环节+最大重复次数)

    参考:http://www.cnblogs.com/jackge/archive/2013/01/05/2846006.html 总结一下,如果对于next数组中的 i, 符合 i % ( i - n ...

  8. Uva - 12230 Crossing Rivers (数学期望)

    你住在村庄A,每天需要过很多条河到另一个村庄B上班,B在A的右边,所有的河都在A,B之间,幸运的是每条船上都有自由移动的自动船, 因此只要到达河左岸然后等船过来,在右岸下船,上船之后船的速度不变.现在 ...

  9. 简谈Java传值传引用

    本随笔旨在强化理解传值与传引用   如下代码的运行结果 其中i没有改变,s也没有改变. 但model中的值均改变了. i :100s :hellomodel :testchangemodel2 :ch ...

  10. springmvc json 数据

    这里是controllor层 @RequestMapping("/traceupdatestatus") @ResponseBody public boolean traceupd ...