贪心,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. 关于FTP操作的功能类

    自己在用的FTP类,实现了检查FTP链接以及返回FTP没有反应的情况. public delegate void ShowError(string content, string title); // ...

  2. android -- 蓝牙 bluetooth (三)搜索蓝牙

    接上篇打开蓝牙继续,来一起看下蓝牙搜索的流程,触发蓝牙搜索的条件形式上有两种,一是在蓝牙设置界面开启蓝牙会直接开始搜索,另一个是先打开蓝牙开关在进入蓝牙设置界面也会触发搜索,也可能还有其它触发方式,但 ...

  3. ceph存储之查找对象

    对象存储(而非块存储): 要把对象存入ceph集群,客户端必须做到: 1.指定对象名 2.指定存储池 Ceph客户端检出最新集群运行图,客户端用CRUSH算法动态地计算出如何把对象映射到归置组.然后计 ...

  4. linux下安装greenplum

    1. 下载 Greenplum Database 源代码 $ git clone https://github.com/greenplum-db/gpdb 2. 安装依赖库 Greenplum Dat ...

  5. excel列显示形式互换(字母与数字)

    以office2007为例: excel选项>公式>使用公式下的'R1C1引用样式' 打上钩显示形式为数字,不打钩显示形式为字母

  6. 【集训笔记】计算几何【HDOJ2036【HDOJ1086【HDOJ1115【HDOJ1147【HDOJ1392 【ZOJ2976

    改革春风吹满地 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted ...

  7. (Problem 21)Amicable numbers

    Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into ...

  8. django ImageField用法

    settings里的设置 PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname('__file__'))) MEDIA_ROOT = ...

  9. Gradle构建Java Web应用:Servlet依赖与Tomcat插件(转)

    Gradle的官方tutorial介绍了构建Java Web应用的基本方法.不过在使用Servlet做上传的时候会碰到问题.这里分享下如何通过Servlet上传文件,以及如何使用Gradle来构建相应 ...

  10. 一起学习CMake – 02

    本节介绍如何用CMake来设置软件的版本号 在<一起学习CMake - 01>中我们看到了如何用CMakeLists.txt来构建一个最简单的工程,这一节里我们一起来看看如何用CMake对 ...