【题解】 UVa11729 Commando War】的更多相关文章

G Commando War Input: Standard Input Output: Standard Output “Waiting for orders we held in the wood, word from the front never came By evening the sound of the gunfire was miles away Ah softly we moved through the shadows, slip away through the tree…
题目大意 你有n个部下,每个部下需要完成一项任务.第i个部下需要你花Bj分钟交代任务,然后他就会立刻独立地.无间断地执行Ji分钟后完成任务.你需要选择交代任务的顺序,使得所有任务尽早执行完毕(即最后一个执行完的任务应尽早结束).注意,不能同时给两个部下交代任务,但部下们可以同时执行他们各自的任务. Solution 还是考虑贪心对吧,我们觉得如果一个人要执行的时间越长肯定就先安排,这个是可以证明的. 现在有两个士兵,他们的值分别为:{b1,j1},{b2,j2}(假设j1>j2) 那么我们分别安…
相邻两个士兵交换顺序,不会对其他的有所影响,贪心考虑两两之间交换策略即可. sort大法好.印象中这类排序题里有一种会卡sort,只能冒泡排序,然而到现在还没有遇到 /**/ #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; struct node{ int b; int j; }; int cmp(const node a…
贪心法,执行任务的时间J越长的应该越先交待.可以用相邻交换法证明正确性.其实对于两个人,要让总时间最短,就要让同一时间干两件事的时间最长. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<map> #include<set> #inc…
Commando War“Waiting for orders we held in the wood, word from the front never cameBy evening the sound of the gunfire was miles awayAh softly we moved through the shadows, slip away through the treesCrossing their lines in the mists in the fields on…
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 commando squad at your disposal and planning an ambush on an important enemy camp located nearby. You have N soldiers in your squad. In…
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 commando squad at your disposal and planning an ambush on an important enemy camp located nearby. You have N soldiers…
题目传送门 /* 贪心:按照执行时间长的优先来排序 */ #include <cstdio> #include <algorithm> #include <iostream> #include <cstring> #include <string> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; struct Node { int b, j; bo…
1446. [Commando War,Uva 11729]突击战 ★   输入文件:commando.in   输出文件:commando.out   简单对比时间限制:1 s   内存限制:64 MB [题目描述] 你有n个部下,每个部下需要完成一项任务.第i个部下需要你花Bi分钟交代任务,然后他会立刻独立地,无间断的执行Ji分钟后完成任务.你需要交代任务的顺序,使得所有的任务尽早执行完毕.注意,不能同时给2个部下交代任务,但是部下可以同时执行各自的任务. [输入格式] 输入数据包括多组数据…
你有n个部下,每个部下需要完成一项任务.第i个部下需要你花Bi分钟交待任务,然后他会立刻独立地.无间断地执行Ji分钟后完成任务.你需要选择交待任务的顺序,使得所有任务尽早执行完毕(即最后一个执行完的任务应尽早结束).注意,不能同时给两个部下交待任务,但部下们可以同时执行他们各自的任务. [输入格式] 输入包含多组数据,每组数据的第一行为部下的个数N(1≤N≤1 000):以下N行每行两个正整数B和J(1≤B≤10 000,1≤J≤10 000),即交待任务的时间和执行任务的时间.输入结束标志为N…