1446. [Commando War,Uva 11729]突击战 ★   输入文件:commando.in   输出文件:commando.out   简单对比时间限制:1 s   内存限制:64 MB [题目描述] 你有n个部下,每个部下需要完成一项任务.第i个部下需要你花Bi分钟交代任务,然后他会立刻独立地,无间断的执行Ji分钟后完成任务.你需要交代任务的顺序,使得所有的任务尽早执行完毕.注意,不能同时给2个部下交代任务,但是部下可以同时执行各自的任务. [输入格式] 输入数据包括多组数据…
https://vjudge.net/problem/UVA-11729 题意:有n个部下,每个部下需要完成一项任务.第i个部下需要你话B分钟交代任务,然后立刻执行J分钟完成任务.安排交代任务顺序并计算出所有任务完成的最少时间. 思路:贪心. 把执行任务长的先交代了. 每个任务都有各自的开始执行时间,也就是当这个任务交代完时,它就开始执行任务.接下来计算出完成任务时的时间,每次更新最晚的任务完成时间即可. #include<iostream> #include<algorithm>…
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…
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…
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…
 例2:假设当前小光有n个部下,每个部下需要完成一项任务.第i个部下需要小光花Bi分钟交代任务,然后他会立刻独立地.无间断地执行Ji分钟后完成任务.小光需要选择交代任务的顺序,使得所有任务尽早执行完毕(即最后一个执行完的任务应尽早结束).注意,不能同时给两个部下交代任务,但部下们可以同时执行他们各自的任务.Input 输入包含多组数据,每组数据的第一行为部下的个数n(1<=n<=1000):以下n行,每行两个正整数B和J(1<=B<=10000,1<=J<=10000)…
突击战 你有n个部下,每个部下需要完成一项任务.第i个部下需要你花Bi分钟交待任务,然后他会立刻独立地. 无间断地执行Ji分钟后完成任务.你需要选择交待任务的顺序, 使得所有任务尽早执行完毕(即最后一个执行完的任务应尽早结束) .注意,不能同时给两个部下交待任务,但部下们可以同时执行他们各自的任务. [输入] 输入包含多组数据,每组数据的第一行为部下的个数N(1≤N≤1 000):以下N行每行两个正整数B和J(1≤B≤10 000,1≤J≤10 000),即交待任务的时间和执行任务的时间.输入结…
你有 n 个部下,每个部下需要完成一个任务.第 i 个部下需要你花 Bi 分钟交待任务,然后他会立刻独立地.无间断地执行 Ji 分钟后完成任务.你需要选择交待任务的顺序,使得所有任务尽早执行完毕(即最后一个执行完的任务尽早结束).注意,不能同时给两个部下交待任务,但部下们可以同时执行他们各自的任务. 既然是要尽早完成任务,当然执行时间长的先交待,先执行.所以对所有数据按执行时间从大到小的顺序进行排序,然后开始处理,通过更新最晚的时间来得到最终结果. 简单的贪心,附上AC代码: 1: #inclu…