All submissions for this problem are available.
This problem is referred from Hackerearth.
As NIT Puducherry’s Knosys 15’s robot building competition was approaching, the organizers decided to make the competition a little more interesting with a new set of rules. According to the new set of rules, the robot with the maximum VISION will be announced as the winner.
Now, VISION of a robot is defined by ( C* P ) % 1000000007, where
C = number of robots standing in front of it which can be seen by it + number of robots he can see behind it which can be seen by it.
P = position of the robot in a given scenario ( The robot array is 1-N indexed )
As all the robots are standing in a queue, one behind the other, a robot i cannot see beyond another robot j if height of robot j >= height of robot i
First line of the input contains T, the number of test cases. The 1st line of each test case consists of a single integer n, the number of robots. Second line contains n space separated integers R, R, R...R[n] denoting the heights of the robots 1, 2, 3....n.
Output for each test case should be a single line displaying the index of the winning robot. In case of ties, display the robot with minimum index.
- 0 < T ≤ 50
- 1 < n ≤ 105
- 0 ≤ R[i] ≤ 106
2 5 4 1 2 1 4 5 5 1 2 4 1Output:
|Time Limit:||- 1 sec|
|Source Limit:||500000 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, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.