poj 2431 Expedition 贪心

2014-11-23 23:18:26 · 作者: · 浏览: 6
简单的说说思路,如果一开始能够去到目的地那么当然不需要加油,否则肯定选择能够够着的油量最大的加油站加油,,不断重复这个贪心的策略即可。
#include   
#include   
#include   
#include   
#include   
using namespace std;  
const int maxn=1e4+9;  
int dist,p,n;  
struct S  
{  
    int d,f;  
    bool operator <(const S & xx) const  
    {  
        return d
,cmp> q; while(p