hdu 1029 Ignatius and the Princess IV

来源:互联网 发布:歌未竟 东方白 知乎 编辑:程序博客网 时间:2024/06/06 00:57

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029
简单题,stl水之。。

#include<algorithm>#include<cstdio>#include<map>using std::map;map<int,int> rec;int main() {    int n, v, res, cnt;    while (~scanf("%d", &n)) {        res = cnt = 0;        for (int i = 0; i < n; i++) {            scanf("%d", &v);            rec[v]++;            if (rec[v] > cnt) cnt = rec[v], res = v;        }        printf("%d\n", res);        rec.clear();    }    return 0;}
0 0
原创粉丝点击