基础题,计算出发时间大于等于 0 的人的最早到达时间。(出发时间为负的人,要么追不上,要么速度比自己慢,不用考虑)
#include <iostream>
#include <cmath>
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
int N;
while (cin >> N)
{
if (N == 0)
break;
int v, t; //速度,出发时间
int ans = INF;
for (int i = 0; i < N; i++)
{
cin >> v >> t;
if (t < 0)
continue;
int arrive = ceil(4.5 * 3600 / v) + t; //到达时间
if (arrive < ans)
ans = arrive;
}
cout << ans << endl;
}
return 0;
}
继续加油。