#C3735. Determine the Winner with Unique Highest Card
Determine the Winner with Unique Highest Card
Determine the Winner with Unique Highest Card
In this problem, you are given the number of players and the cards dealt to each player. Each player is dealt exactly one card. Your task is to determine which player wins the round by having a uniquely highest card. If there is a tie for the highest card (i.e. the maximum card value appears more than once), then the result is -1
.
Formally, let (n) be the number of players and let (cards = [a_0, a_1, \dots, a_{n-1}]) be a list of integers representing the card values dealt. You need to find the index (i) such that (a_i = \max{a_0, a_1, \dots, a_{n-1}}) and this maximum appears only once. If the maximum value is not unique, output (-1).
inputFormat
The input is given from standard input and consists of two lines:
- The first line contains a single integer (n) --- the number of players.
- The second line contains (n) space-separated integers, where the (i)-th integer represents the card dealt to the (i)-th player.
outputFormat
Output a single integer to the standard output: the index of the winning player if there is a uniquely highest card; otherwise, output (-1).## sample
5
2 5 7 3 7
-1
</p>