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. HDU - 4544 湫湫系列故事——消灭兔子(优先队列+贪心)

    题目: 最近,减肥失败的湫湫为发泄心中郁闷,在玩一个消灭免子的游戏. 游戏规则很简单,用箭杀死免子即可. 箭是一种消耗品,已知有M种不同类型的箭可以选择,并且每种箭都会对兔子造成伤害,对应的伤害值分别 ...

  2. 零基础入门学习Python(2)--用Python设计第一个游戏

    前言 小甲鱼的Python课程都是围绕着一个个小游戏,进行Python的讲解,由易入难. 小游戏流程图 Created with Raphaël 2.1.2Startprint('---------- ...

  3. Django之Ajax提交

    Ajax 提交数据,页面不刷新 Ajax要引入jQuery Django之Ajax提交 Js实现页面的跳转: location.href = "/url/" $ajax({ url ...

  4. 77-CCI,Commodity Channel Index,商品通道指标.(2015.7.1)

    CCI,Commodity Channel Index 商品通道指标 Channel Index,商品通道指标.(2015.7.1)" title="77-CCI,Commodit ...

  5. Leetcode 220.存在重复元素III

    存在重复元素III 给定一个整数数组,判断数组中是否有两个不同的索引 i 和 j,使得 nums [i] 和 nums [j] 的差的绝对值最大为 t,并且 i 和 j 之间的差的绝对值最大为 ķ. ...

  6. 数据结构-B+树

    B+ 树是一种树数据结构,是一个n叉排序树,每个节点通常有多个孩子,一棵B+树包含根节点.内部节点和叶子节点.根节点可能是一个叶子节点,也可能是一个包含两个或两个以上孩子节点的节点. B+ 树通常用于 ...

  7. idea导入(import)项目和打开(open)项目的区别

    前言: 每次接手老项目,都得从git或svn下载下来,但是如果之前的项目不是用idea写的怎么办,可是你又习惯啦idea,那你必须把项目在idea上跑起来,那是用import还是用open呢,如何抉择 ...

  8. [NOIP2005] 提高组 洛谷P1053 篝火晚会

    题目描述 佳佳刚进高中,在军训的时候,由于佳佳吃苦耐劳,很快得到了教官的赏识,成为了“小教官”.在军训结束的那天晚上,佳佳被命令组织同学们进行篝火晚会.一共有n个同学,编号从1到n.一开始,同学们按照 ...

  9. codevs2597 团伙

    题目描述 Description 1920年的芝加哥,出现了一群强盗.如果两个强盗遇上了,那么他们要么是朋友,要么是敌人.而且有一点是肯定的,就是: 我朋友的朋友是我的朋友: 我敌人的敌人也是我的朋友 ...

  10. 修改xampp的mysql默认密码

    MySQL 的“root”用户默认状态是没有密码的,所以在 PHP 中您可以使用 mysql_connect("localhost","root"," ...