贪心 UVA 11729 Commando War
/*
贪心:按照执行时间长的优先来排序
*/
#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的更多相关文章
- Uva 11729 Commando War (简单贪心)
Uva 11729 Commando War (简单贪心) There is a war and it doesn't look very promising for your country. N ...
- 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 ...
- UVa 11729 - Commando War(贪心)
"Waiting for orders we held in the wood, word from the front never came By evening the sound of ...
- [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 ...
- UVa 11729 Commando War 【贪心】
题意:有n个部下,交待每个部下完成他相应的任务需要bi的时间,然后完成这项任务需要ji的时间, 选择交待任务的顺序,使得总的花费的时间最少 因为不管怎么样,交待所需要的n*bi的时间都是要花费的, 然 ...
- UVa 11729 - Commando War
[题目翻译]: 题目分析:因为任务是可以并行的执行,所以直觉上是花费时间长的任务优先去部署.但是这到题目还给你交待任务的时间,所以容易让人想多了. 不管有没有交待任务的时间,对于任务x和y,只可能有两 ...
- UVa 11729 Commando War 突击战
你有 n 个部下,每个部下需要完成一个任务.第 i 个部下需要你花 Bi 分钟交待任务,然后他会立刻独立地.无间断地执行 Ji 分钟后完成任务.你需要选择交待任务的顺序,使得所有任务尽早执行完毕(即最 ...
- Commando War
Commando War“Waiting for orders we held in the wood, word from the front never cameBy evening the so ...
- cogs 1446. [Commando War,Uva 11729]突击战
1446. [Commando War,Uva 11729]突击战 ★ 输入文件:commando.in 输出文件:commando.out 简单对比时间限制:1 s 内存限制:64 ...
随机推荐
- Android TextView内容过长加省略号
在Android TextView中有个内容过长加省略号的属性,即ellipsize,用法如下: 在xml中: android:ellipsize = "end" //省略号在结尾 ...
- Thinkphp5.0 控制器向视图view赋值
Thinkphp5.0 控制器向视图view的赋值 方式一(使用fetch()方法的第二个参数赋值): <?php namespace app\index\controller; use thi ...
- [bzoj2733][HNOI2012]永无乡_权值线段树_线段树合并
永无乡 bzoj-2733 HNOI-2012 题目大意:题目链接. 注释:略. 想法: 它的查询操作非常友善,就是一个联通块内的$k$小值. 故此我们可以考虑每个联通块建一棵权值线段树. 这样的话每 ...
- cogs——2084. Asm.Def的基本算法
2084. Asm.Def的基本算法 ★☆ 输入文件:asm_algo.in 输出文件:asm_algo.out 简单对比时间限制:1 s 内存限制:256 MB [题目描述] “有句 ...
- Connection节点配置错误解决方案
问题:配置错误 说明: 在处理向该请求提供服务所需的配置文件时出错.请检查下面的特定错误详细信息并适当地修改配置文件.分析器错误信息: 无法识别的配置节“connectionStrings”源错误:行 ...
- 链表倒置,这个还是考验仔细程度,第一遍还没做对 —— 剑指Offer
https://www.nowcoder.net/practice/75e878df47f24fdc9dc3e400ec6058ca?tpId=13&tqId=11168&tPage= ...
- tornado的http服务器实现
使用tornado实现的一个简单http服务器:只需要定义自己的处理方法,其他的东西全部交给tornado完成. #coding:utf-8 import tornado.httpserver imp ...
- Linux学习系列之LNMP
LNMP介绍 LNMP是什么 LNMP(Linux-Nginx-MySQL-PHP)网站架构是目前国际流行的Web架构; 这四种软件组合,可以成为一个免费.高效.扩展性强的Web架构; LNMP原理图 ...
- [VueJS + Typescript] Decouple Dependencies Using IoC Containers in Vue with TypeScript and InversifyJS
Using Object Oriented Programming, OOP, style allows us to apply Inversion of Control, IoC, and more ...
- 卷积神经网络-进化史】从LeNet到AlexNet
目录视图 摘要视图 订阅 [置顶] [卷积神经网络-进化史]从LeNet到AlexNet 标签: cnn 卷积神经网络 深度学习 2016年05月17日 23:20:3046038人阅读 评论(4) ...