Ride to Office

Description [title]

Start and end points separated by 4500 meters. Charley ride now required from start to finish. However, he has a habit, need someone along the way, that at the same speed, ride with another person. And when he met people faster ride, he will keep up with the faster people with the appropriate speed. Give Charley given all those who go the same way and with the speed of their departure time, Charley asked in such a way with people, how much time riding finish 4500 meters required. If the result decimal, the rounding up.

[Enter]

A plurality of input data sets, each data line of the first n (1≤n≤10000), n is 0, indicates the end of input, then the input data n rows, each row 2 data, and the departure time indicates the speed v t, if t <0, which means companion to early departure.

[Output]

Data corresponding to a plurality of output lines, each output line number 1, represents the fastest time of arrival.

[Sample input]

4
20 0
25 -155
27 190
30 240
2
21 0
22 34
0

[Sample Output]

780
771

Problem-solving ideas: people who follow the rider to ride in the first to arrive will be the final time Charley, that the current time t + 4500 / (v * 1000 /3600) ( This unit is to be turned into seconds and the number of kilometers per hour meters ) so much time to find the minimum value to
#include <bits / STDC ++ H.>
the using namespace STD;
int n-, ANS, V, T, I;
int main ()
{
    the while (Scanf ( "% D", & n-) && n-)
    {
  ANS = 1E9;
  for (int I =. 1; I <= n-; I ++)
  {
   Scanf ( "% D% D", & V, & T);
   IF (T> = 0)
   {
    int CUR = ceil (T + 4.5 of 5 / V * 3600);
    ANS = min (ANS, CUR);
    
    }
   }
  the printf ( "% D \ n-", ANS);
  
  }
 return 0;
}

Guess you like

Origin www.cnblogs.com/macren/p/11828850.html