贪心,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. JSP TAG

    Jsp tag 能够灵活的将公共JSP代码模块化,类似<jsp:include page="./include.jsp"></jsp:include>等等. ...

  2. hdu4513之manacher算法

    吉哥系列故事——完美队形II Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) T ...

  3. Ext JS学习第四天 我们所熟悉的javascript(三)

    此文用来记录学习笔记: •javascript之函数 •this关键字的使用 –this关键字总是指向调用者,谁调用函数,this就指向谁 •call.apply的使用 –call和apply主要应用 ...

  4. unity学习中经常要碰到的几种数据结构

    常碰到的几种数据结构:1.Array,2.ArrayList,3.List<T>,4.LinkedList<T>,5.Queue<T>,6.Stack<T&g ...

  5. 数据库数据用Excel导出的3种方法

    将数据库数据用Excel导出主要有3种方法:用Excel.Application接口.用OleDB.用HTML的Tabel标签 方法1——Excel.Application接口: 首先,需要要Exce ...

  6. android: 长按删除listview的item

    转自:http://www.cnblogs.com/nuistlr/archive/2012/09/07/2675649.html 首先要继承OnItemLongClickListener publi ...

  7. instanceof 变量是否属于某一类 class 的实例

    <?phpclass MyClass{} class NotMyClass{}$a = new MyClass;$b = new NotMyClass;var_dump($a instanceo ...

  8. Flowers(二分水过。。。)

    Flowers Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  9. BZOJ 3477: [Usaco2014 Mar]Sabotage( 二分答案 )

    先二分答案m, 然后对于原序列 A[i] = A[i] - m,  然后O(n)找最大连续子序列和, 那么此时序列由 L + mx + R组成. L + mx + R = sum - n * m, s ...

  10. xml学习(1)xml的几种文件格式

    1.先简单介绍一下XML,xml 是基于文本的标记性行语言,类似于html,可以方便存储数据 2,XML文件的几种格式: 格式1:查看一个 XML 的 CD 目录 <?xml version=& ...