codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

780B.md (2042B)


      1 Source: https://codeforces.com/problemset/problem/780/B
      2 
      3 B. The Meeting Place Cannot Be Changed
      4 
      5 time limit per test
      6 
      7 5 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 The main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost building in north direction.
     22 
     23 At some points on the road there are *n* friends, and *i*-th of them is standing at the point *x**i* meters and can move with any speed no greater than *v**i* meters per second in any of the two directions along the road: south or north.
     24 
     25 You are to compute the minimum time needed to gather all the *n* friends at some point on the road. Note that the point they meet at doesn't need to have integer coordinate.
     26 
     27 Input
     28 
     29 The first line contains single integer *n* (2 ≤ *n* ≤ 60 000) — the number of friends.
     30 
     31 The second line contains *n* integers *x*1, *x*2, ..., *x**n* (1 ≤ *x**i* ≤ 109) — the current coordinates of the friends, in meters.
     32 
     33 The third line contains *n* integers *v*1, *v*2, ..., *v**n* (1 ≤ *v**i* ≤ 109) — the maximum speeds of the friends, in meters per second.
     34 
     35 Output
     36 
     37 Print the minimum time (in seconds) needed for all the *n* friends to meet at some point on the road.
     38 
     39 Your answer will be considered correct, if its absolute or relative error isn't greater than 10- 6. Formally, let your answer be *a*, while jury's answer be *b*. Your answer will be considered correct if ![](https://espresso.codeforces.com/354edc27fee211170922d7a154f57d15b2eb8afb.png) holds.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 3  
     47 7 1 3  
     48 1 2 1
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 2.000000000000
     55 ```
     56 
     57 Input
     58 
     59 ```
     60 4  
     61 5 10 3 2  
     62 2 3 2 4
     63 ```
     64 
     65 Output
     66 
     67 ```
     68 1.400000000000
     69 ```
     70 
     71 Note
     72 
     73 In the first sample, all friends can gather at the point 5 within 2 seconds. In order to achieve this, the first friend should go south all the time at his maximum speed, while the second and the third friends should go north at their maximum speeds.