文章

37

粉丝

1

获赞

312

访问

7.2k

头像
求众数 题解:
P1810 复旦大学机试
发布于2026年3月10日 14:53
阅读数 74

#include<bits/stdc++.h>
using namespace std;

int main(){
	map<int,int> mp;
	int n; cin>>n;
	for(int i = 0 ; i < n; i++){
		int t; cin>>t;
		mp[t]++;
	}
	int ans = 0;
	int count = 0;
	for(auto it : mp){
		if(it.second > count){
			count = it.second;
			ans = it.first;
		}
	}
	cout<<ans<<endl;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发