#K76147. Most Popular App
Most Popular App
Most Popular App
This problem involves finding the most popular app based on survey data. Given a list of integer app IDs, your task is to determine the app that appears most frequently. In the event of a tie, choose the app with the smallest ID.
You can mathematically express the frequency of an app ID \(i\) as \(f(i)\). The goal is to find the app ID \(i\) that maximizes \(f(i)\), and if there are multiple such IDs, the smallest one should be chosen.
inputFormat
The first line of input contains an integer (n), the number of survey records. The second line contains (n) space-separated integers representing the app IDs.
outputFormat
Output two space-separated integers: the most popular app ID and its corresponding frequency. In case of a tie (i.e. multiple apps have the same highest frequency), output the smallest app ID among them.## sample
1
1
1 1