当前位置: 代码迷 >> 综合 >> Flying to the Mars
  详细解决方案

Flying to the Mars

热度:47   发布时间:2023-10-26 22:07:57.0

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1800
很久没用容器的*max_element了,忘了怎么加排序规则了。记录一下。

#include<bits/stdc++.h>
//#define maxn 100010
using namespace std;
typedef pair<int, int>  P;
map<int,int> a;
bool cmp(const P& p1,const P& p2)
{return p1.second<p2.second;
}
int main()
{int n;while(cin>>n){int tmp;for(int i=0;i<n;i++){scanf("%d",&tmp);a[tmp]++;}int x = (*max_element(a.begin(),a.end(),cmp)).second;
// int ans = 0;
// for(map<int,int>::iterator it = a.begin();it!=a.end();it++)
// {
    
// if(it->second>ans)
// ans = it->second;
// }
// cout<<ans<<endl;cout<<x<<endl;a.clear();}return 0;
}