ACM: 贪心题 uva 11729
来源:互联网 发布:电脑网络连接显示未知 编辑:程序博客网 时间:2024/05/23 10:36
G CommandoWar
“Waiting for orders we held in the wood, word from the front nevercame
By evening the sound of the gunfire was miles away
Ah softly we moved through the shadows, slip away through thetrees
Crossing their lines in the mists in the fields on our hands andour knees
And all that I ever, was able to see
The fire in the air, glowing red, silhouetting the smoke on thebreeze”
There is a war and it doesn't look very promising for your country.Now it's time to act. You have a commando squad at your disposaland planning an ambush on an important enemy camp located nearby.You have N soldiers in your squad. In your master-plan, everysingle soldier has a unique responsibility and you don't want anyof your soldier to know the plan for other soldiers so thateveryone can focus on his task only. In order to enforce this, youbrief every individual soldier about his tasks separately and justbefore sending him to the battlefield. You know that every singlesoldier needs a certain amount of time to execute his job. You alsoknow very clearly how much time you need to brief every singlesoldier. Being anxious to finish the total operation as soon aspossible, you need to find an order of briefing your soldiers thatwill minimize the time necessary for all the soldiers to completetheir tasks. You may assume that, no soldier has a plan thatdepends on the tasks of his fellows. In other words, once asoldier
Input
There will be multiple test cases in the input file. Every testcase starts with an integer N(1<=N<=1000), denoting the number ofsoldiers. Each of the following N lines describe a soldier with twointegers B (1<=B<=10000)& J (1<=J<=10000). Bseconds are needed to brief the soldier while completing his jobneeds J seconds. The end of input will be denoted by a case with N=0 . This case should not be processed.
Output
For each test case, print a line in the format, “Case X: Y”, whereX is the case number & Y is the total number ofseconds counted from the start of your first briefing till thecompletion of all jobs.
Sample Input
3
2 5
3 2
2 1
3
3 3
4 4
5 5
0
Output for Sample Input
Case 1: 8
Case 2: 15
题意: 现在你有N个任务需要完成, 有足够的士兵, 你分析你的问题给他需要Bi时间, 他执行的时间Ji时间;
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
#define MAX 1005
struct node
{
};
int n;
inline int max(int a, int b)
{
}
int main()
{
//
}
0 0
- ACM: 贪心题 uva 11729
- ACM: 贪心题 poj 1083
- ACM: uva 1335 - Beijing Guards
- ACM: uva 10391 - Compound Words
- ACM: uva 10534 - Wavio Sequence
- ACM: uva 11538 - Chess Queen
- ACM: uva 1073 - Glenbow Museum
- ACM: uva 11464
- ACM: uva 3902
- ACM: uva 10382
- ACM: uva 11134
- ACM: 简单题 uva 10881
- ACM: 动态规划题 uva 11825
- ACM: 二分题 uva 11627
- ACM: 数学题 uva 11300
- ACM: uva 11584 -
- ACM: uva 1276 - Network
- ACM: uva 1450 - Airport
- ACM: 动态规划题 poj&nb…
- ACM: 计算几何题 poj 2066
- ACM: 动态规划题 黑书-…
- ACM: 搜索题 poj 1…
- ACM: 极其简单题 uva&nb…
- ACM: 贪心题 uva 11729
- ACM: 数学题 uva 11300
- ACM: 简单题 uva 10881
- ACM: zoj 2714
- ACM: uva 11464
- ACM: 暴力题 poj 2741
- ACM: uva 11210 &n…
- 一步一步搭建客服系统
- ACM: 二分题 poj 3497