Just Finish it up Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu [Submit] [Go Back] [Status] Description I I U P C 2 0 0 6 Problem J: Just Finish it up Input: standard input Output: standard output Along a circular tr…
题意:环形跑道上有N个加油站,编号为1~N.第 i 个加油站可以加油Ai加仑,从加油站 i 开到下一站需要Bi加仑汽油.问可作为起点走完一圈后回到起点的最小加油站编号. 解法:我们把每个加油站的Ai,Bi合并,把Ai-Bi看成N个点的权Ci,表示经过 i 的剩余油量.可知可通过第 i 个加油站就是sum{}+Ci>=0,sum{}表示从起点开到 i 之前剩余的油量,sum{}>=0.因此,若sum{}+Ci<0,那么从这时枚举的起点到 i 之间的所有点都不能作为起点,因为这时的sum{}…
https://vjudge.net/problem/UVA-11093 题意:环形跑道上有n个加油站,编号为1~n.第i个加油站可以加油pi加仑,从加油站i开到下一站需要qi加仑汽油.输出最小的起点,使得可以走完一圈后回到起点. 思路:直接枚举.注意剪枝就可以了,如从1号加油站出发,开到加油站p前没油了,那么2,3,4...p-1肯定不是解. #include<iostream> using namespace std; + ; int n; int ans; int p[maxn]; in…
"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…