Your new room in the office

0

0 votes
Easy
Problem

You are a hardworking employee at endurance. The board is happy with your hard work and they decide to give you your own office room.This office's architecture is slightly different than traditional / conventional offices. Your office has N rooms in one line but every room is situated at a different height. Now, you want a room with maximum sight of other rooms and also has a nice position so, you come up with a solution i.e. to maximize the value of

(x * x * p) % (10^9 + 7)

in your room, where x and p are as follows:

x = number of rooms he can see left of him + number of rooms he can see right of him
p = position of the room in a given scenario ( index of the array is 1−N indexed )

As all the rooms are in a straight line, when he is in room no i cannot see beyond another room j if height of j>= height of i.

Input:
First line contains t, the number of test cases. The 1st line of each test case consists of a single integer n, the number of rooms. Second line contains n space separated integers h[1], h[2],...h[n] denoting the heights of the rooms 1,2,3....n.

Output:
Output for each test case should be a single line displaying the index of the most suitable office room. In case of ties, display the room with minimum index.

Conatraints:
0<= t <=60
0<= n <= 10^5
0<=h[i]<= 10^6

Setter: Jinesh Shah

Sample Input
2
5
4 1 2 1 5
4
1 1 1 1
Sample Output
5
3
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?