Chefu and Billi
All submissions for this problem are available.
There is a very sweet girl Chefu in NIT Jalandhar.Chef's friend billi likes her very much. But unfortunately she was proposed by n boys(numbered from 1 to N) of the college to be their valentine this 14th. She also loves billi but she doesn't want to break others heart so she decided to play a game with them. She makes all of them drunk and makes them stand at x=0,y=0 and herself at x=D ,y=0.The walking style of the ith Drunk boy is such that he always goes A steps forward and B steps backward, but everyone takes equal time to move one step of unit distance . Chefu will accept the proposal of that guy who reaches her first.So you have to tell, Who will be her valentine this year.
If two boys came simultaneously,boy with lower number will be the valentine.
After reaching chefu , boy will not go backwards
First Line contains T=No. of test Cases
For each test case-
First line contains a single integer N denoting the no. of boys.
Next line contains N space separated integers ,ith integer denotes A - the no. of forward steps moved by ith boy.
Next line contains N space separated integers ,ith integer denotes B - the no.of backward steps moved by ith boy.
Next line contains single integer D.
The Number of boy who will be chefu's valentine in new line for every test case
0 < B < A<=10^9
Sample Test Case:
1 2 3 4 5
0 1 2 3 4
5 7 9 11
4 3 2 3
In the first case,
Boy1 will go 1 step forward and 0 backward.So, he will reach in 10 steps
Boy2 will go 2 steps forward and 1 backward. So, in 3 steps he moves a distance of 1, thereby reaching destination in 26 steps.
Boy3 will go 3 steps forward and 2 backward. So, in 5 steps he moves a distance of 1, thereby reaching destination in 38 steps.
Boy4 will go 4 steps forward and 3 backward. So, in 7 steps he moves a distance of 1, thereby reaching destination in 46 steps.
Boy5 will go 5 steps forward and 4 backward. So, in 9 steps he moves a distance of 1, thereby reaching destination in 50 steps.
|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, SCALA, 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, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions