MAP的插入 你可长点心吧233333
#include <stdio.h>
#include <map>
using namespace std;
int main() {
int m, n, curr, res;
map<int, int> g;
scanf("%d%d", &m, &n);
int num = m * n;
int half = num / 2;
for (int i = 1; i <= num; ++i) {
scanf("%d", &curr);
g[curr]++;
if (g[curr] >= half)
res = curr;
}
printf("%d\n", res);
return 0;
}
网友评论