题目传送门

 /*
贪心:按照执行时间长的优先来排序
*/
#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. 【周期性执行事件】MySQL事件(Event)&任务调度

    1.事件简介 事件(event)是MySQL在相应的时刻调用的过程式数据库对象.一个事件可调用一次,也可周期性的启动,它由一个特定的线程来管理的,也就是所谓的“事件调度器”. 事件和触发器类似,都是在 ...

  2. ZOJ - 3829 Known Notation(模拟+贪心)

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 给定一个字符串(只包含数字和星号)可以在字符串的任意位置添加一个数字 ...

  3. ACM组队安排-——杭电校赛(递推)

    #include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #in ...

  4. P1547 Out of Hay 洛谷

    https://www.luogu.org/problem/show?pid=1547 题目背景 奶牛爱干草 题目描述 Bessie 计划调查N (2 <= N <= 2,000)个农场的 ...

  5. AutoCAD如何打印

    现在有一个CAD图纸,左侧为房型图,右侧为规划好之后的图纸,我只要打印右侧的东西.点击文件-打印   在打印设备中选择Default Windows System Printer,名称的下拉菜单下面有 ...

  6. JS 获取form表单的所有数据

    在HTML中用js获取通过GET.POST方法(就是在网址后加?a=b&c=d之类)传过来的表单值. 针对大家常用的获取表单方式,很多时候都是在重复的写一些代码,今天给大家贴出来的代码可以作为 ...

  7. 华为OJ2011-最长公共子串

    一.题目描述 描述: 计算两个字符串的最大公共子串(Longest Common Substring)的长度,字符区分大小写. 输入: 输入两个字符串 输出: 输出一个整数 样例输入: asdfas ...

  8. ubuntu上跑python连接pg,报错 ImportError: No module named psycopg2

    ubuntu上跑python连接pg,报错  ImportError: No module named psycopg2 root@pgproxy1:~# python /home/zxw/PGWri ...

  9. Android在onCreate()方法中动态获取TextView控件的高度

    正好朋友项目里遇到了给写了个小Demo: 这个监听器看名字也知道了.就是在绘画完毕之前调用的,在这里面能够获取到行数.当然也能够获取到宽高等信息 package com.example.textvie ...

  10. SpringMVC之请求参数的获取方式

    转载出处:https://www.toutiao.com/i6510822190219264516/ SpringMVC之请求参数的获取方式 常见的一个web服务,如何获取请求参数? 一般最常见的请求 ...