poj2431Expedition】的更多相关文章

Description A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Being rather poor drivers, the cows unfortunately managed to run over a rock and puncture the truck's fuel tank. The truck now leaks one unit of fuel ever…
解题方法详见<挑战程序设计竞赛(第二版)>P74-75.注意首先要对加油站以位置为关键字快排,不要遗忘把终点视作一个加油量为0的加油站,否则最终只能到达终点前的加油站. /*优先队列*/ #include<iostream> #include<cstdio> #include<algorithm> #include<queue> using namespace std; +; struct rec { int pos,oil; bool oper…
题目大意:卡车每走一公里就消耗一单位的汽油,初始时给你p单位油,你要到达l距离的终点.其中路上有n个补给点可以加油,并且油箱容量无限大,问你最少可以停车几次. 思路:因为油箱无限大,所以我们可以这么认为,我们路过一个加油站之后,我们在之后的路上随时可以选择加那个加油站的油,而且肯定是一次加完B_i,所以我们从汽车初始状态开始开,到没油了,看看路上路过有加油站没,选路过过油最多的,加上,继续这样.最后加油次数一定是最少的 #include<cstdio> #include<queue>…
A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Being rather poor drivers, the cows unfortunately managed to run over a rock and puncture the truck's fuel tank. The truck now leaks one unit of fuel every unit of di…