POJ 1922 Ride to School

一道简单的贪心题目

直接判断每个人到达终点的时间就行了

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
inline int read(){
    int x=0,f=1,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
    int n=read();
    while(n){
        int ans=0x3f3f3f3f;
        for(int i=1;i<=n;i++){
            int v=read(),t=read();
            if(t<0) continue;
            int v1=ceil(4500*3.6/v);
            ans=min(ans,v1+t);
        }
        printf("%d\n",ans);
        n=read();
    }
    return 0;
}

  

posted @ 2018-10-27 22:58  古城独钓  阅读(183)  评论(0)    收藏  举报