Chef and Junction
All submissions for this problem are available.India has some of the most spectacular and unforgettable rail journeys in the world. Here you experience a simple way to find out everything you need to know in one easy place. There's no better way to enjoy India's outback, cities, coastal towns and regional areas in comfort. So, Junction in railway is a point where two or more rail route converge or diverge. Suppose, there are $N$ trains running in route East to West. The position of ith train is $'xi' $, and it is running with a velocity $'vi'$. Train can run in any of the direction either East to West or West to East. Chef asks you to tell whether it is possible that 'n' trains meet at a junction, if possible then you have to tell the minimum possible time at which they meet. $Note :- $ Meeting point is not compulsory to be an integer coordinate. ###Input: - The first line contains single integer $N$ — the number of trains. - The second line contains n integers x1, x2, ..., xn — the current coordinates of the trains, in meters. - The third line contains n integers v1, v2, ..., vn — the maximum speeds of the trains, in meters per second. ###Output: Print the minimum time (in seconds) needed for all the n trains to meet at some point on the road, if it is not possible then print '-1'. - Your answer will be considered correct, if its correct upto 30 decimal places.. ###Constraints - $2 \leq N \leq 6000$ - $2 \leq xi,vi \leq 10^9$ ###Sample Input: 3 7 1 3 1 2 1 ###Sample Output: 1.999999999999999555910790149937 ###EXPLANATION: all trains can meet at the point 5 within around 2 seconds.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.