"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 trees Crossing their lines in the mists in the fields on our hand…
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…
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…
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 your master-p…
题意:有n个部下,交待每个部下完成他相应的任务需要bi的时间,然后完成这项任务需要ji的时间, 选择交待任务的顺序,使得总的花费的时间最少 因为不管怎么样,交待所需要的n*bi的时间都是要花费的, 然后就让完成任务需要的时间长的人先做,就将j按降序排,更新每完成一个人的任务所花费的时间 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stac…
[题目翻译]: 题目分析:因为任务是可以并行的执行,所以直觉上是花费时间长的任务优先去部署.但是这到题目还给你交待任务的时间,所以容易让人想多了. 不管有没有交待任务的时间,对于任务x和y,只可能有两种情况.x在y之前结束,和x在y之后结束.这里讨论x在y之前完成. 未交换x和y的位置时,完成时间为:B[x] + B[y] + J[y] 交换h和y位置之后,完成时间为:B[y] + B[x] + J[x] 如果J[y] 大于J[x],那么交换后,时间变短了,所以应该将y放在x之前执行.另一种情况…
你有 n 个部下,每个部下需要完成一个任务.第 i 个部下需要你花 Bi 分钟交待任务,然后他会立刻独立地.无间断地执行 Ji 分钟后完成任务.你需要选择交待任务的顺序,使得所有任务尽早执行完毕(即最后一个执行完的任务尽早结束).注意,不能同时给两个部下交待任务,但部下们可以同时执行他们各自的任务. 既然是要尽早完成任务,当然执行时间长的先交待,先执行.所以对所有数据按执行时间从大到小的顺序进行排序,然后开始处理,通过更新最晚的时间来得到最终结果. 简单的贪心,附上AC代码: 1: #inclu…
1446. [Commando War,Uva 11729]突击战 ★   输入文件:commando.in   输出文件:commando.out   简单对比时间限制:1 s   内存限制:64 MB [题目描述] 你有n个部下,每个部下需要完成一项任务.第i个部下需要你花Bi分钟交代任务,然后他会立刻独立地,无间断的执行Ji分钟后完成任务.你需要交代任务的顺序,使得所有的任务尽早执行完毕.注意,不能同时给2个部下交代任务,但是部下可以同时执行各自的任务. [输入格式] 输入数据包括多组数据…
贪心法,执行任务的时间J越长的应该越先交待.可以用相邻交换法证明正确性.其实对于两个人,要让总时间最短,就要让同一时间干两件事的时间最长. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<map> #include<set> #inc…