HDU 4070 Phage War
贪心,t 大的放到前面。。。因为感染所有cell需要的phage的总数是一定的,所以产生phage需要的时间是一定的,只需要考虑用来感染的时间,这样考虑的话,把 t 小的放后面的话,可以发现总时间的最少的。
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath> #define LL long long
#define CLR(a, b) memset(a, b, sizeof(a)) using namespace std; const int N = 111111; struct Cell
{
int d, t;
bool operator < (const Cell& rhs) const
{
return t > rhs.t;
}
}C[N]; int main()
{
int t, cas = 1, n, i, j, ans, sum;
scanf("%d", &t);
while(t --)
{
scanf("%d", &n);
for(i = 0; i < n; i ++)
{
scanf("%d%d", &C[i].d, &C[i].t);
}
sort(C, C + n);
sum = ans = 0;
for(i = 0; i < n; i ++)
{
sum += C[i].d;
ans = max(ans, sum + C[i].t);
}
printf("Case %d: %d\n", cas ++, ans);
}
}
HDU 4070 Phage War的更多相关文章
- HDU 4070 + 赤裸裸的贪心~~
J - Phage War Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Phage ...
- HDU 4005 The war(双连通好题)
HDU 4005 The war pid=4005" target="_blank" style="">题目链接 题意:给一个连通的无向图.每条 ...
- hdu 4005 The war
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4005 In the war, the intelligence about the enemy is ...
- HDU 4005 The war Tarjan+dp
The war Problem Description In the war, the intelligence about the enemy is very important. Now, o ...
- HDU 4005 The war (图论-tarjan)
The war Problem Description In the war, the intelligence about the enemy is very important. Now, our ...
- hdu 4070 福州赛区网络赛J 贪心 ***
优先发路程最长的 #include<cstdio> #include<iostream> #include<algorithm> #include<cstri ...
- HDU 4005 The war 双连通分量 缩点
题意: 有一个边带权的无向图,敌人可以任意在图中加一条边,然后你可以选择删除任意一条边使得图不连通,费用为被删除的边的权值. 求敌人在最优的情况下,使图不连通的最小费用. 分析: 首先求出边双连通分量 ...
- HDU 4005 The war(边双连通)
题意 给定一张 \(n\) 个点 \(m\) 条边的无向连通图,加入一条边,使得图中权值最小的桥权值最大,如果能使图中没有桥则输出 \(-1\). 思路 先对原图边双缩点,然后变成了一棵树.在 ...
- Tarjan & LCA 套题题目题解
刷题之前来几套LCA的末班 对于题目 HDU 2586 How far away 2份在线模板第一份倍增,倍增还是比较好理解的 #include <map> #include <se ...
随机推荐
- springmvc-3.2-jsr303解决服务端验证问题
从以前的验证:Stringutils.isEmpty....到struts的验证:xxxvalidate 现在使用jsr303使之更加简单 依赖hibernate-validator-4.xx.ja ...
- 基于visual Studio2013解决C语言竞赛题之0509杨辉三角
题目
- Global文件(修正篇)
什么是Global文件 Global.asax文件俗称为一个类,继承于Httpapplication类.位于应用程序根目录下.也可称为应用程序文件. 概述: Global文件是可选的,一般在创建应用程 ...
- 非确定有限状态自动机的构建(二)——将CharVal转换为NFA
保留版权,转载注明出处:潘军彪的个人博客(http://blog.csdn.net/panjunbiao/article/details/9378933) 将上下文无关文法读入内存之后,可以将它转换成 ...
- c语言中float、double、long double在内存中存储方式
存储格式中的二机制转为浮点数: 浮点型变量在计算机内存中占用4个字节(4 Byte),即32-bit,一个浮点数由2部分组成:底数m 和 指数e: 底数部分:使用2进制数来表示此浮点数的实际值: 指 ...
- 常见的transformation 和 Action
常见transformation map 将RDD中的每个元素传入自定义函数,获取一个新的元素,然后用新的元素组成新的RDD filter 对RDD中每个元素进行判断,如果返回true则保留,返回fa ...
- css之display:inline-block与float区别(可以尝试用一下)
HTML的元素有多种display属性,比较常见的有display:none; display:block; display:inline和display:inline-block;等.详细可参阅W3 ...
- 工作随记 warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
错误信息:F:\BUILD\IDS7020\trunk\manage_src\dev\java_src\tds7030-web\Ant\build.xml:344: warning: 'include ...
- Android 锁屏状态/锁屏密码等相关
Android 锁屏状态/锁屏密码等相关 开始是在设备管理器方面找方法,但一直不行,可能在公司系统组同事的帮助下,知道KeyguardManager这个类 /** * 当前系统锁屏是否有密码 * @p ...
- perl 回调必须是函数引用
[root@wx03 lib]# cat a1.pl use AE; use AnyEvent; ##定义watch my $t = AnyEvent->timer( after => 0 ...