题目传送门

 /*
贪心:按照执行时间长的优先来排序
*/
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
using namespace std; const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
struct Node {
int b, j;
bool operator < (const Node &r) const {
return j > r.j;
}
}node[MAXN]; int main(void) //UVA 11729 Commando War
{
//freopen ("UVA_11729.in", "r", stdin); int n; int cas = ;
while (scanf ("%d", &n) == && n)
{
for (int i=; i<=n; ++i)
{
scanf ("%d%d", &node[i].b, &node[i].j);
} sort (node+, node++n); int ans = ; int mx = -;
for (int i=; i<=n; ++i)
{
ans += node[i].b;
mx = max (mx, ans + node[i].j);
} printf ("Case %d: %d\n", ++cas, mx);
} return ;
} /*
Case 1: 8
Case 2: 15
*/

贪心 UVA 11729 Commando War的更多相关文章

  1. Uva 11729 Commando War (简单贪心)

    Uva 11729  Commando War (简单贪心) There is a war and it doesn't look very promising for your country. N ...

  2. UVA 11729 - Commando War(贪心 相邻交换法)

    Commando War There is a war and it doesn't look very promising for your country. Now it's time to ac ...

  3. UVa 11729 - Commando War(贪心)

    "Waiting for orders we held in the wood, word from the front never came By evening the sound of ...

  4. [ACM_水题] UVA 11729 Commando War [不可同时交代任务 可同时执行 最短完成全部时间 贪心]

    There is a war and it doesn't look very promising for your country. Now it's time to act. You have a ...

  5. UVa 11729 Commando War 【贪心】

    题意:有n个部下,交待每个部下完成他相应的任务需要bi的时间,然后完成这项任务需要ji的时间, 选择交待任务的顺序,使得总的花费的时间最少 因为不管怎么样,交待所需要的n*bi的时间都是要花费的, 然 ...

  6. UVa 11729 - Commando War

    [题目翻译]: 题目分析:因为任务是可以并行的执行,所以直觉上是花费时间长的任务优先去部署.但是这到题目还给你交待任务的时间,所以容易让人想多了. 不管有没有交待任务的时间,对于任务x和y,只可能有两 ...

  7. UVa 11729 Commando War 突击战

    你有 n 个部下,每个部下需要完成一个任务.第 i 个部下需要你花 Bi 分钟交待任务,然后他会立刻独立地.无间断地执行 Ji 分钟后完成任务.你需要选择交待任务的顺序,使得所有任务尽早执行完毕(即最 ...

  8. Commando War

    Commando War“Waiting for orders we held in the wood, word from the front never cameBy evening the so ...

  9. cogs 1446. [Commando War,Uva 11729]突击战

    1446. [Commando War,Uva 11729]突击战 ★   输入文件:commando.in   输出文件:commando.out   简单对比时间限制:1 s   内存限制:64 ...

随机推荐

  1. 网络编程基础:网络基础之网络协议、socket模块

    操作系统(简称OS)基础: 应用软件不能直接操作硬件,能直接操作硬件的只有操作系统:所以,应用软件可以通过操作系统来间接操作硬件 网络基础之网络协议: 网络通讯原理: 连接两台计算机之间的Intern ...

  2. android 上AES解密是报错javax.crypto.BadPaddingException: pad block corrupted

    网上看到两种方法: 1.SecretKeySpec skeySpec = new SecretKeySpec(getRawKey(key), "AES"); private sta ...

  3. 【BZOJ3925】地震后的幻想乡(期望概率DP,状压DP)

    题意:给定一张点数不超过10的无向连通图,每条边有一个[0,1]之间的随机权值,求最小生成树上最大边的期望值 提示:对于n个[0,1]之间的随机变量x1,x2,...,xn,第k小的那个的期望值是k/ ...

  4. mysql 之 Workbench的使用

    mysql 之 Workbench的使用 (1)简介 MySQL Workbench是一款专为MySQL设计的ER/数据库建模工具.它是著名的数据库设计工具DBDesigner4的继任者.你可以用My ...

  5. python基础之-字符串

    字符模块:strstr.strip():去掉字符串前后空格str.lstrip():去掉字符串左侧空格str.rstrip():去掉字符串右侧空格str.encode():将字符串编码为二进制str. ...

  6. 前端自动化测试工具--使用karma进行javascript单元测试(转)

    Karma+Jasmine+PhantomJS组合的前端javascript单元测试工具. 1.介绍 Karma是由Google团队开发的一套前端测试运行框架,karma会启动一个web服务器,将js ...

  7. SQL Server中迁移数据的几种方法

    1.通过工具"DTS"的设计器进行导入或者导出 DTS的设计器功能强大,支持多任务,也是可视化界面,容易操作,但知道的人一般不 多,如果只是进行SQL Server数据库中部分表的 ...

  8. oracle11g expdp/impdp数据库

    oracle11g导入/导出数据库 导出 .创建目录 sqlplus / as sysdba create directory dbDir as 'd:\oralce_sdic_backup\'; g ...

  9. Django学习系列之django restframework

    曾几何时,Ajax已经统治了Web开发中的客户端,而REST成为web世界中最流行的架构风格(architecture style).所以我们的选择变得很简单:前端ajax访问后端的RESTful A ...

  10. golang 查询数据库操作

    SQL.Open only creates the DB object, but dies not open any connections to the database. If you want ...