Commando War (贪心)】的更多相关文章

"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…
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…
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…
1446. [Commando War,Uva 11729]突击战 ★   输入文件:commando.in   输出文件:commando.out   简单对比时间限制:1 s   内存限制:64 MB [题目描述] 你有n个部下,每个部下需要完成一项任务.第i个部下需要你花Bi分钟交代任务,然后他会立刻独立地,无间断的执行Ji分钟后完成任务.你需要交代任务的顺序,使得所有的任务尽早执行完毕.注意,不能同时给2个部下交代任务,但是部下可以同时执行各自的任务. [输入格式] 输入数据包括多组数据…
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…
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…
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 hands…
你有n个部下,每个部下需要完成一项任务.第i个部下需要你花Bi分钟交待任务,然后他会立刻独立地.无间断地执行Ji分钟后完成任务.你需要选择交待任务的顺序,使得所有任务尽早执行完毕(即最后一个执行完的任务应尽早结束).注意,不能同时给两个部下交待任务,但部下们可以同时执行他们各自的任务. [输入格式] 输入包含多组数据,每组数据的第一行为部下的个数N(1≤N≤1 000):以下N行每行两个正整数B和J(1≤B≤10 000,1≤J≤10 000),即交待任务的时间和执行任务的时间.输入结束标志为N…
贪心法,执行任务的时间J越长的应该越先交待.可以用相邻交换法证明正确性.其实对于两个人,要让总时间最短,就要让同一时间干两件事的时间最长. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<map> #include<set> #inc…
题意:有n个部下,交待每个部下完成他相应的任务需要bi的时间,然后完成这项任务需要ji的时间, 选择交待任务的顺序,使得总的花费的时间最少 因为不管怎么样,交待所需要的n*bi的时间都是要花费的, 然后就让完成任务需要的时间长的人先做,就将j按降序排,更新每完成一个人的任务所花费的时间 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stac…
传送门:I Am Here 常规解法是贪心,但是在复习最大流的写法,因此用sap来写的.思路是很好想的 #include<cstdio> #include<cstdlib> #include<iostream> #include<cstring> #include<algorithm> #include<memory.h> #include<cmath> using namespace std; const int M=2…
相邻两个士兵交换顺序,不会对其他的有所影响,贪心考虑两两之间交换策略即可. sort大法好.印象中这类排序题里有一种会卡sort,只能冒泡排序,然而到现在还没有遇到 /**/ #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; struct node{ int b; int j; }; int cmp(const node a…
[题目翻译]: 题目分析:因为任务是可以并行的执行,所以直觉上是花费时间长的任务优先去部署.但是这到题目还给你交待任务的时间,所以容易让人想多了. 不管有没有交待任务的时间,对于任务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…
题目大意 你有n个部下,每个部下需要完成一项任务.第i个部下需要你花Bj分钟交代任务,然后他就会立刻独立地.无间断地执行Ji分钟后完成任务.你需要选择交代任务的顺序,使得所有任务尽早执行完毕(即最后一个执行完的任务应尽早结束).注意,不能同时给两个部下交代任务,但部下们可以同时执行他们各自的任务. Solution 还是考虑贪心对吧,我们觉得如果一个人要执行的时间越长肯定就先安排,这个是可以证明的. 现在有两个士兵,他们的值分别为:{b1,j1},{b2,j2}(假设j1>j2) 那么我们分别安…
传送门 Description 给定n个正整数,求他们相连接后能形成的最大整数.例如:12,23这两个数能连接的最大数是2312,. Input 多组数据,每组数据中: 第一行为一个整数n 第二行有n个整数,代表给出的数. 输入结束的标志为n=0. Output 对于每组数据,输出: 能拼成的最大整数 Sample Input Sample Output Hint 1≤n≤50 Solution 简单的贪心.对给出的数进行排序,A在B的前面当且仅当A接上B比B接上A大.最后按顺序输出答案即可.…
1038 Recover the Smallest Number (30 分)   Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229-87 or 0…
UVA 11292 The Dragon of Loowater 题意 给n个头,m个骑士,骑士有能力值x,代表他可以砍掉一个直径不超过x的头,并且佣金为x,求要砍掉所有的头,需要的最少佣金是多少. 类型 贪心 难度 简单 题解 贪心,对n个头进行排序,m个骑士进行排序,对当前的最小x的骑士,如果他可以砍掉最小直径的头,那么雇佣他(显然不存在更好的选择),否则,看下一个骑士是否可以砍掉当前最小直径的未被砍掉的头. UVA 11729 Commando War 题意 给n个部下,每个需要完成一个任…
每周日更新 2016.05.29 UVa中国麻将(Chinese Mahjong,Uva 11210) UVa新汉诺塔问题(A Different Task,Uva 10795) NOIP2012同余方程 NOIP2007统计数字 NOIP2013火柴排队 NOIP2013花匠 2016.06.05 Uva 组装电脑 12124 - Assemble Uva 派 (Pie,NWERC 2006,LA 3635) 2016.06.19 Uva 网络(Network,Seoul 2007,LA 39…
B. War of the Corporations 题目连接: http://www.codeforces.com/contest/625/problem/B Description A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the…
D - The War Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Description A war had broken out because a sheep from your kingdom ate some grasses which belong to your neighboring kingdom. The counselor of your k…
传送门 Description A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000. This new devic…
Long long ago there is a strong tribe living on the earth. They always have wars and eonquer others.One day, there is another tribe become their target. The strong tribe has decide to terminate them!!!There are m villages in the other tribe. Each vil…
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=117&page=show_problem&problem=2829 "Waiting for orders we held in the wood, word from the front never came By evening the sound of the gunfire was miles awa…
A.GPA(HDU4802): 给你一些字符串对应的权重,求加权平均,如果是N,P不计入统计 GPA Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1193    Accepted Submission(s): 743 Problem Description In college, a student may take several…
J - Phage War Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Phage War is a little flash game. In this game, we want infect all cells by the transmission and breed of phages. Originally, there is a cell infected by phage…
1692: [Usaco2007 Dec]队列变换 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1383  Solved: 582[Submit][Status][Discuss] Description FJ打算带他的N(1 <= N <= 30,000)头奶牛去参加一年一度的“全美农场主大奖赛”.在这场比赛中,每个参赛者都必须让他的奶牛排成一列,然后领她们从裁判席前依次走过. 今年,竞赛委员会在接受队伍报名时,采用了一种新的登记规则:他们把所…
过去我们发布一个Java Web程序通常的做法就是把它打成一个war包,然后用SSH这样的工具把它上传到服务器,并放到相应的目录里,让Tomcat自动去解包,完成部署. 很显然,这样做不够方便,且我们在用SSH把文件拽上去的时候很可能会搞错.(当然了大厂就不会有这样的问题,因为人家有运维团队专门来干这个事情,哈哈) 现在我要的是:一行命令部署到本地服务器,在本地测试一番,没有问题的话就一行命令部署到正式服务器,另外正式服务器的密码只有我自己知道,只有我能执行这个部署(其它开发组员不知道正式服务器…