Twice as Large
The maximum is unique. Print its 1-based position if it is at least TWICE every other element, else −1.
Input: the first line has N; the second line has N integers with a unique maximum.
Output: the dominant index, or −1.
Constraints:
- 1 ≤ N ≤ 105
- 0 ≤ ai ≤ 109
Sample Tests
Input 1
4 3 6 1 0
Output 1
2
Input 2
4 1 2 3 4
Output 2
-1
Discussion (opens after you solve — no spoilers before)
No comments yet.