#P10786. Finding the Customer with Maximum Deposit
Finding the Customer with Maximum Deposit
Finding the Customer with Maximum Deposit
At Small Y's bank, there are \(N\) customers numbered from \(0\) to \(N-1\). The \(i\)-th customer holds \(W_i\) units in deposits. It is guaranteed that all \(W_i\) are distinct. Small P, a close partner of Small Y, wants to know which customer has the highest deposit.
However, Small P cannot directly access the deposit amounts. Instead, he can only make a series of requests. Each request is comprised of several queries. In each query, given a pair \((i, j)\), the bank responds with \(i\) if \(W_i > W_j\), otherwise it responds with \(j\). There is an upper limit on the number of requests and the total number of queries.
Your task is to help Small P determine the customer with the maximum deposit using these comparisons. In this problem, you are provided with the full list of deposit values offline. You simply need to output the index of the customer with the highest deposit.
inputFormat
The first line contains an integer \(N\) representing the number of customers. The second line contains \(N\) space-separated integers \(W_0, W_1, \ldots, W_{N-1}\) representing the deposit amounts of each customer.
outputFormat
Output a single integer denoting the index of the customer with the maximum deposit.
sample
5
100 50 200 150 80
2