码迷,mamicode.com
首页 > 其他好文 > 详细

POJ 1922 Ride to School

时间:2018-10-27 23:32:42      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:pre   lin   ret   getch   cpp   for   return   std   ==   

一道简单的贪心题目

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

#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;
}

  

POJ 1922 Ride to School

标签:pre   lin   ret   getch   cpp   for   return   std   ==   

原文地址:https://www.cnblogs.com/gcyyzf/p/9863836.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!