POJ:2431-Expedition】的更多相关文章

POJ 2431 Expedition(探险) Time Limit: 1000MS   Memory Limit: 65536K [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 an…
poj:4091:The Closest M Points 题目 描写叙述 每到饭点,就又到了一日几度的小L纠结去哪吃饭的时候了.由于有太多太多好吃的地方能够去吃,而小L又比較懒不想走太远,所以小L会先找到距离他近期的M家餐馆然后再做筛选. 小L如今所在的位置和每家餐馆的位置用同一笛卡尔坐标系中的点表示,而点与点之间的距离为欧几里得距离,对于点p = (p1, p2,..., pn)和点q = (q1,q2,..., qn),两者的距离定义例如以下 现给出在K维空间中小L所处的位置的坐标以及n个…
Expedition Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8053   Accepted: 2359 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…
http://poj.org/problem?id=2431 你需要驾驶一辆卡车做一次长途旅行,但是卡车每走一单位就会消耗掉一单位的油,如果没有油就走不了,为了修复卡车,卡车需要被开到距离最近的城镇,在当前位置和城镇之间有n个加油站可以加油. 为了减少危险,需要最少的加油次数,卡车的油箱可以看作无限大,卡车初始距离城镇L单位,自身有P单位的油. 注意输入的距离是与城镇的距离不是与开始点的距离.转换一下就好. 思想:把经过的所有加油站都加入优先队列,当燃料不足时就取出优先队列的最大元素,用来给卡车…
题目地址:POJ 2431 将路过的加油站的加油量放到一个优先队列里,每次当油量不够时,就一直加队列里油量最大的直到能够到达下一站为止. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #include <ctype.h> #inc…
题目链接:http://poj.org/problem?id=2431 题意:一辆卡车要行驶L单位距离,卡车上有P单位的汽油.一共有N个加油站,分别给出加油站距终点距离,及加油站可以加的油量.问卡车能否到达终点?若不能输出-1,否则求出最少加油次数. 解题思路:可以认为"在到达加油站时,获得一次可以在任何时候使用这个加油站加油的资格",而在之后需要加油时,就认为是在之前经过的加油站加的油就可以了.因为希望加油次数最少,所以在燃料不够行驶时选择加油量最大的加油站加油.为了高效性,我们可以…
链接:http://poj.org/problem?id=2431 题解 #include<iostream> #include<algorithm> #include<queue> using namespace std; ; int N,L,P; //N是加油站数,L是路程,P是初始燃料量 struct node{ int a, b; //a是加油站到城镇(终点)的距离,b是每个加油站燃料量 }code[MAX_N]; bool comp(node x, node…
Expedition Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12980   Accepted: 3705 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 t…
题目链接 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…
Expedition Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18655   Accepted: 5405 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 t…