CF637A.Voting for Photos
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: the photo which gets most likes wins. If multiple photoes get most likes, the winner is the photo that gets this number first.
Help guys determine the winner photo by the records of likes.
期中庆祝活动结束后,伯兰国立大学某学院的学生们决定举行一次“最佳照片”投票。他们将照片发布在社交网络上,并商定了如下评选规则:获得点赞数最多的照片获胜;若有多张照片并列获得最多的点赞数,则最先达到该点赞数的照片获胜。
请帮助同学们根据点赞记录确定获胜的照片。
输入格式
The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the total likes to the published photoes.
The second line contains n positive integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 1 000 000), where a__i is the identifier of the photo which got the i-th like.
输入的第一行包含一个整数 n(1≤n≤1000)—— 表示发布的照片获得的总点赞数。
第二行包含 n 个正整数 a1, a2, …, an(1≤ai≤1000000),其中 ai 表示获得第 i 个点赞的照片的编号。
输出格式
Print the identifier of the photo which won the elections.
输出赢得选举的照片的标识符。
输入输出样例
输入#1
5 1 3 2 2 1
输出#1
2
输入#2
9 100 200 300 200 100 300 300 100 200
输出#2
300
说明/提示
In the first test sample the photo with id 1 got two likes (first and fifth), photo with id 2 got two likes (third and fourth), and photo with id 3 got one like (second).
Thus, the winner is the photo with identifier 2, as it got:
- more likes than the photo with id 3;
- as many likes as the photo with id 1, but the photo with the identifier 2 got its second like earlier.
在第一个测试样例中,编号为 1 的照片获得了两个赞(第一次和第五次),编号为 2 的照片也获得了两个赞(第三次和第四次),而编号为 3 的照片获得了一个赞(第二次)。
因此,获胜者是编号为 2 的照片,因为它:
- 获得的赞数多于编号为 3 的照片;
- 获得的赞数与编号为 1 的照片相同,但编号为 2 的照片获得第二个赞的时间更早。
输入解题思路,AI测评打分。不知道怎么写?