VK Cup 2016 - Qualification Round 1 (Russian-Speaking Only, for VK Cup teams) A. Voting for Photos 水题

时间:2022-12-13 19:11:22

A. Voting for Photos

题目连接:

http://www.codeforces.com/contest/637/problem/A

Description

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.

Input

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 a1, a2, ..., an (1 ≤ ai ≤ 1 000 000), where ai is the identifier of the photo which got the i-th like.

Output

Print the identifier of the photo which won the elections.

Sample Input

5

1 3 2 2 1

Sample Output

2

Hint

题意

给你n个数,然后问你哪个数出现的次数最多,如果有多个数出现次数一样多,就输出第一个那么多次数的数。

题解:

开个map随便搞搞就好了……

代码

#include<bits/stdc++.h>
using namespace std; map<int,int>H; int main()
{
int n;scanf("%d",&n);
int ans1 = 0,ans2 = 0;
for(int i=1;i<=n;i++)
{
int x;scanf("%d",&x);
H[x]++;
if(H[x]>ans2)ans1=x,ans2=H[x];
}
cout<<ans1<<endl;
}

VK Cup 2016 - Qualification Round 1 (Russian-Speaking Only, for VK Cup teams) A. Voting for Photos 水题的更多相关文章

  1. VK Cup 2016 - Qualification Round 2 B&period; Making Genome in Berland

    今天在codeforces上面做到一道题:http://codeforces.com/contest/638/problem/B 题目大意是:给定n个字符串,找到最短的字符串S使得n个字符串都是这个字 ...

  2. VK Cup 2016 - Qualification Round 2 D&period; Three-dimensional Turtle Super Computer 暴力

    D. Three-dimensional Turtle Super Computer 题目连接: http://www.codeforces.com/contest/638/problem/D Des ...

  3. VK Cup 2016 - Qualification Round 2 C&period; Road Improvement dfs

    C. Road Improvement 题目连接: http://www.codeforces.com/contest/638/problem/C Description In Berland the ...

  4. VK Cup 2016 - Qualification Round 2 B&period; Making Genome in Berland 水题

    B. Making Genome in Berland 题目连接: http://www.codeforces.com/contest/638/problem/B Description Berlan ...

  5. VK Cup 2016 - Qualification Round 2 A&period; Home Numbers 水题

    A. Home Numbers 题目连接: http://www.codeforces.com/contest/638/problem/A Description The main street of ...

  6. VK Cup 2016 - Qualification Round 1 &lpar;Russian-Speaking Only&comma; for VK Cup teams&rpar; D&period; Running with Obstacles 贪心

    D. Running with Obstacles 题目连接: http://www.codeforces.com/contest/637/problem/D Description A sports ...

  7. VK Cup 2016 - Qualification Round 1 &lpar;Russian-Speaking Only&comma; for VK Cup teams&rpar; C&period; Promocodes with Mistakes 水题

    C. Promocodes with Mistakes 题目连接: http://www.codeforces.com/contest/637/problem/C Description During ...

  8. VK Cup 2016 - Qualification Round 1 &lpar;Russian-Speaking Only&comma; for VK Cup teams&rpar; B&period; Chat Order 水题

    B. Chat Order 题目连接: http://www.codeforces.com/contest/637/problem/B Description Polycarp is a big lo ...

  9. VK Cup 2016 - Qualification Round 1——A&period; Voting for Photos(queue&plus;map)

    A. Voting for Photos time limit per test 1 second memory limit per test 256 megabytes input standard ...

随机推荐

  1. 使用valgrind检查内存

    Valgrind是运行在Linux上一套基于仿真技术的程序调试和分析工具,是公认的最接近Purify的产品,它包含一个内核——一个软件合成的CPU,和一系列的小工具,每个工具都可以完成一项任务——调试 ...

  2. mysql存储过程中字符串参数单引号

    注意:存储过程中单引号  ,四个单引号 SET @sql = CONCAT('select user_id into ',m_user_id,' from go_user where mobile = ...

  3. Java比较器对数组,集合排序一

    数组排序非常简单,有前辈们的各种排序算法,再加上Java中强大的数组辅助类Arrays与集合辅助类Collections,使得排序变得非常简单,如果说结合比较器Comparator接口和Collato ...

  4. 分享一个牛逼的PHP无限极分类生成树方法,巧用引用&lpar;转&rpar;

    你还在用浪费时间又浪费内存的递归遍历无限极分类吗,看了该篇文章,我觉得你应该换换了.这是我在OSChina上看到的一段非常精简的PHP无限极分类生成树方法,巧在引用,整理分享了. function g ...

  5. 【LigerUI】ajax请求firefox返回NS&lowbar;BINDING&lowbar;ABORTED

    在ligergrid中请求链接,post提交,返回NS_BINDING_ABORTED. 是因为ligergrid中默认是异步提交方式,如果没有设置同步的话, 在请求该链接的时候第一次请求还没有执行完 ...

  6. Android 内存泄漏分析与解决方法

    在分析Android内存泄漏之前,先了解一下JAVA的一些知识 1. JAVA中的对象的创建 使用new指令生成对象时,堆内存将会为此开辟一份空间存放该对象 垃圾回收器回收非存活的对象,并释放对应的内 ...

  7. 从本地上传项目到 github 以及从github 下载项目到本地环境

    前置条件:成功安装github,安装成功后,要配置密钥,不然上传不成功,要报错 具体上传步骤: git init   //初始化 git add  文件名  //更新文件 git commit -m ...

  8. elment ui 图片上传遇到的一些问题

    图片上传返回200,message显示请上传图片 注意上图中的name字段要和服务器接受的name相同,这里我们是imgfile,默认name不是这个,所以要在el-upload组件上设置name属性 ...

  9. 2018&period;9青岛网络预选赛&lpar;A&rpar;

    传送门:Problem A https://www.cnblogs.com/violet-acmer/p/9664805.html 题意: 求m个PERFECTs中最多有多少个连续的PERFECT和最 ...

  10. 微信支付 php兼容问题

    总结: php7 已删除 HTTP_RAW_POST_DATA  获取时需要file_get_contents("php://input"); 下面的是兼容方法. //存储微信的回 ...