描述
Many staff of are living in a place called MZone, far from their office( 4.5 km ). Due to the bad traffic, many staff choose to ride a bike.
We may assume that all the people except "Weiwei" ride from home to office at a fixed speed. Weiwei is a people with a different riding habit – he always tries to follow another rider to avoid riding alone. When Weiwei gets to the gate of MZone, he will look for someone who is setting off to the Office. If he finds someone, he will follow that rider, or if not, he will wait for someone to follow. On the way from his home to office, at any time if a faster student surpassed Weiwei, he will leave the rider he is following and speed up to follow the faster one.
There are several test cases. The first line of each case is N (1 <= N <= 10000) representing the number of riders (excluding Weiwei). N = 0 ends the input. The following N lines are information of N different riders, in such format:
Vi [TAB] Ti
4
20 0
25 -155
27 190
30 240
2
21 0
22 34
780
771
题意:
MZone中除了Weiwei的人都以固定的速度骑自行车到办公室,Weiwei则总是跟着别人。Weiwei在0时刻到达MZone的大门,他会寻找一个人跟随。如果有人在0时刻出发,他就会跟随那个人,否则他会等着,直到有人出发。在路上,如果一个更快的人超过了魏伟,他将跟随那个更快的人。
MZone到办公室的距离为4.5km。
只需算出出发时间t>=0的陪伴人到达终点的时间就可以了
weiwei一定会和出发时间t>=0并且最先到达的陪伴人同时到达
Many staff of are living in a place called MZone, far from their office( 4.5 km ). Due to the bad traffic, many staff choose to ride a bike.
We may assume that all the people except "Weiwei" ride from home to office at a fixed speed. Weiwei is a people with a different riding habit – he always tries to follow another rider to avoid riding alone. When Weiwei gets to the gate of MZone, he will look for someone who is setting off to the Office. If he finds someone, he will follow that rider, or if not, he will wait for someone to follow. On the way from his home to office, at any time if a faster student surpassed Weiwei, he will leave the rider he is following and speed up to follow the faster one.
We assume the time that Weiwei gets to the gate of MZone is zero. Given the set off time and speed of the other people, your task is to give the time when Weiwei arrives at his office.
There are several test cases. The first line of each case is N (1 <= N <= 10000) representing the number of riders (excluding Weiwei). N = 0 ends the input. The following N lines are information of N different riders, in such format:
Vi [TAB] Ti
Vi is a positive integer <= 40, indicating the speed of the i-th rider (kph, kilometers per hour). Ti is the set off time of the i-th rider, which is an integer and counted in seconds. In any case it is assured that there always exists a nonnegative Ti.
Output one line for each case: the arrival time of Weiwei. Round up (ceiling) the value when dealing with a fraction.
4
20 0
25 -155
27 190
30 240
2
21 0
22 34
0
780
771
题意:
MZone中除了Weiwei的人都以固定的速度骑自行车到办公室,Weiwei则总是跟着别人。Weiwei在0时刻到达MZone的大门,他会寻找一个人跟随。如果有人在0时刻出发,他就会跟随那个人,否则他会等着,直到有人出发。在路上,如果一个更快的人超过了魏伟,他将跟随那个更快的人。
MZone到办公室的距离为4.5km。
给出n个人的速度v(km/h)和出发时间t(s),求Weiwei到达办公室的时间(s)。
只需算出出发时间t>=0的陪伴人到达终点的时间就可以了
weiwei一定会和出发时间t>=0并且最先到达的陪伴人同时到达
而对于出发时间t<0的陪伴人, weiwei肯定追不上
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
const double INF=1e40;
int n;
double v, t, T;
int main() {
while( ~scanf( "%d", &n ) ) {
if( !n ) break;
T=INF;
for( int i=1; i<=n; i++ ) {
scanf( "%lf%lf", &v, &t );
if( t>=0 ) {
t=t+45*360/v;
T=min( T, t );
}
}
printf( "%d\n", (int)(T+0.99) );
}
return 0;
}