贪心,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的更多相关文章

  1. HDU 4070 + 赤裸裸的贪心~~

    J - Phage War Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Phage ...

  2. HDU 4005 The war(双连通好题)

    HDU 4005 The war pid=4005" target="_blank" style="">题目链接 题意:给一个连通的无向图.每条 ...

  3. hdu 4005 The war

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4005 In the war, the intelligence about the enemy is ...

  4. HDU 4005 The war Tarjan+dp

    The war Problem Description   In the war, the intelligence about the enemy is very important. Now, o ...

  5. HDU 4005 The war (图论-tarjan)

    The war Problem Description In the war, the intelligence about the enemy is very important. Now, our ...

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

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

  7. HDU 4005 The war 双连通分量 缩点

    题意: 有一个边带权的无向图,敌人可以任意在图中加一条边,然后你可以选择删除任意一条边使得图不连通,费用为被删除的边的权值. 求敌人在最优的情况下,使图不连通的最小费用. 分析: 首先求出边双连通分量 ...

  8. HDU 4005 The war(边双连通)

    题意 ​ 给定一张 \(n\) 个点 \(m\) 条边的无向连通图,加入一条边,使得图中权值最小的桥权值最大,如果能使图中没有桥则输出 \(-1\). 思路 ​ 先对原图边双缩点,然后变成了一棵树.在 ...

  9. Tarjan & LCA 套题题目题解

    刷题之前来几套LCA的末班 对于题目 HDU 2586 How far away 2份在线模板第一份倍增,倍增还是比较好理解的 #include <map> #include <se ...

随机推荐

  1. Parrot源代码分析之海贼王

    我们的目的是找到speedup-example在使用Parrot加速的原因,假设仅仅说它源于Context Switch的降低,有点简单了,它究竟为什么降低了?除了Context Switch外是否还 ...

  2. iTextSharp.text的一个使用,主要用来创建PDF

    using iTextSharp.text; //创建一个字体来使用和编码格式 BaseFont baseFont = BaseFont.CreateFont("C:\\Windows\\F ...

  3. 使用Intel编译器获得一致的浮点数值计算结果

    使用Intel编译器获得一致的浮点数值计算结果大多数十进制的浮点数, 用二进制表示时不是完全一致的; 与此同时, 大多数与浮点数值相关的计算结果, 存在着固有的不确定性.通常, 编写浮点计算应用软件希 ...

  4. ThinkPHP分页类

    第一种:利用Page类和limit方法 $User = M('User'); // 实例化User对象$count      = $User->where('status=1')->cou ...

  5. mvc导航配置(View页面)

    @using Seyoit.Website.Config@using Seyoit.Website.Config.Navigation@{ var action = ViewContext.Route ...

  6. ORACLE存储过程笔记3

    ORACLE存储过程笔记3 流程控制 1.条件   if expression thenpl/sql or sqlend if;   if expression thenpl/sql or sqlel ...

  7. GlusterFS常用命令

    1.启动/关闭/查看glusterd服务 # /etc/init.d/glusterd start # /etc/init.d/glusterd stop # /etc/init.d/glusterd ...

  8. DH11数字温湿度传感器

    DH11数字温湿度传感器是一种集温度.湿度一体的复合传感器,它能把温度和湿度物理量通过温.湿度敏感元件和相应电路转化成方便计算机.PLC.智能仪表等数据采集设备直接读取的数字量.DHT11由电阻式感湿 ...

  9. 常见的transformation 和 Action

    常见transformation map 将RDD中的每个元素传入自定义函数,获取一个新的元素,然后用新的元素组成新的RDD filter 对RDD中每个元素进行判断,如果返回true则保留,返回fa ...

  10. iconv 文件编码转换

    iconv 文件编码转换 http://www.cnblogs.com/xuxm2007/archive/2010/11/09/1872379.html 查看iconv的支持的编码: $ iconv  ...