CF24E binary (attention should be paid to the processing details of binary and binary)

Source: Internet
Author: User

CF24E binary (attention should be paid to the processing details of binary and binary)

 

 

E. Berland collider time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output

Recently the construction of Berland collider has been completed. Collider can be represented as a long narrow tunnel that containsNParticipant. we associate with collider 1-dimen1_coordinate system, going from left to right. for each particle we know its coordinate and velocity at the moment of start of the collider. the velocities of the participant don't change after the launch of the collider. berland scientists think that the big bang will happen at the first collision of participation, whose velocities differs in directions ctions. help them to determine how much time elapses after the launch of the collider before the big bang happens.

Input

The first line contains single integerN(1 digit ≤ DigitNLimit ≤ limit 5 · 105)-amount of particles in the collider. NextNLines contain description of particle. Each particle is described by two integersXI,VI(Cost-limit 109 limit ≤ limitXI, Bytes,VILimit ≤ limit 109, limit,VIBytes = bytes 0)-coordinate and velocity respectively. all the coordinates are distinct. the participating are listed in order of increasing of coordinates. all the coordinates are in meters, and all the velocities-in meters per second. the negative velocity means that after the start of collider the particle will move to the left, and the positive-that the particle will move to the right.

Output

If there will be no big bang, output-1. otherwise output one number-how much time in seconds elapses after the launch of the collider before the big bang happens. your answer must have a relative or absolute error less than 10 seconds-since 9.

Sample test (s) input
3-5 90 15 -1
Output
1.00000000000000000000
Input
61 32 33 34 -35 -16 -100
Output
0.02912621359223301065
/** CF24E: There are n points on the X axis. Each point emits a bullet to the left or right, knowing the coordinates of each point and the flying speed of the bullets, to solve the problem of the shortest meeting time for all the bullets that face each other: we cannot enumerate the points in the two directions. We need to take the two-point time method. Because the precision is too small, it may fall into an infinite loop, we can limit the number of binary operations */# include
 
  
# Include
  
   
# Include
   
    
# Include using namespace std; const int maxn = 500005; int n, a [maxn] [2]; bool judge (double t) {double d =-1e20; for (int I = 0; I
    
     
0) d = max (d, a [I] [0] + t * a [I] [1]); else if (a [I] [0] + t * a [I] [1] <= d) return true;} return false;} int main () {while (~ Scanf (% d, & n) {for (int I = 0; I
     
      

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.