文章

37

粉丝

1

获赞

353

访问

24.6k

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

#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;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发