#K59652. Song with the Highest Likes
Song with the Highest Likes
Song with the Highest Likes
You are given a playlist with N songs and an array of integers representing the like counts of each song. Your task is to determine the index of the song with the highest like count. In case there are multiple songs with the same highest like count, choose the one that appears first in the playlist.
Note: The indexing starts from 0. You should read the input from stdin
and output the result to stdout
.
The problem can be mathematically formulated as follows:
Given an integer \(N\) and an array \(A = [a_0, a_1, \dots, a_{N-1}]\), find the smallest index \(i\) such that \(a_i = \max\{a_0, a_1, \dots, a_{N-1}\}\).
inputFormat
The first line of input contains a single integer \(N\) representing the number of songs.
The second line contains \(N\) space-separated integers, where the \(i\)-th integer denotes the like count of the \(i\)-th song.
outputFormat
Output a single integer representing the index of the song with the highest like count. In case of ties, output the smallest index.
## sample5
10 20 20 10 30
4