ac
2025-06-26 20:34:35
发布于:上海
46阅读
0回复
0点赞
#include <iostream>
#include <cstring>
using namespace std;
const int MAXN = 100010; // 数值最大为10^5,数组大小设为100010
int cnt[MAXN]; // 计数数组,用于统计每个数值出现的次数
int main() {
int n;
cin >> n;
memset(cnt, 0, sizeof(cnt)); // 初始化计数数组
// 读入怪兽数值并统计次数
for (int i = 0; i < n; i++) {
int x;
cin >> x;
cnt[x]++;
}
int max_count = 0;
// 遍历计数数组,找到出现次数的最大值
for (int i = 1; i < MAXN; i++) {
if (cnt[i] > max_count) {
max_count = cnt[i];
}
}
cout << max_count << endl; // 输出结果
return 0;
}
这里空空如也
有帮助,赞一个