RE求助
  • 板块P2681 众数
  • 楼主Tanhaoyue2011
  • 当前回复10
  • 已保存回复10
  • 发布时间2025/7/23 15:07
  • 上次更新2025/7/23 18:50:17
查看原帖
RE求助
561638
Tanhaoyue2011楼主2025/7/23 15:07
#include<iostream>
#define ll long long

using namespace std;

ll n,m,a[1005],op,x,y,maxn,M;
int ZhongShu(int A, int b){
	int ed[1005];
	for(int i = A; i <= b; i++){
		int o = a[i];
		ed[o]++;
	}
	for(int i = 1; i <= maxn; i++){
		if(ed[i] > M) M = a[ed[i]];
	}
	return M;
}
int main(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(a[i] > maxn) maxn = a[i];
	}
	for(int i = 1; i <= m; i++){
		cin >> op;
		if(op == 0){
			cin >> x >> y;
			cout << ZhongShu(x, y) << endl;
		} else if(op == 1){
			cin >> x >> y;
			a[x] = y;
		} else {
			continue;
		}
	}
	return 0;
}
2025/7/23 15:07
加载中...