标签: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;
}
标签:pre lin ret getch cpp for return std ==
原文地址:https://www.cnblogs.com/gcyyzf/p/9863836.html