POJ 1922 Ride to School

Posted gcyyzf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
",ans);
        n=read();
    }
    return 0;
}

  

以上是关于POJ 1922 Ride to School的主要内容,如果未能解决你的问题,请参考以下文章

2778:Ride to School-poj

HDU 1445Ride to School

The boy wanted to ride his bicycle in the street,

1227:Ride to Office

Ride to Office

1.1.1 Your Ride Is Here