就是经常看到的寻找主元素问题
#include <iostream>
typedef long long LL;
using namespace std;
int main() {
// std::cout << "Hello, World!" << std::endl;
int M,N;
cin>>N>>M;
LL array[M*N];
for (int i = 0; i < M * N; ++i) {
cin>>array[i];
}
int target=array[0];
int count=1;
for (int j = 1; j < M*N; ++j) {
if(target==array[j]){
count++;
} else{
count--;
if(count<=0){
target=array[j];
count=1;
}
}
}
cout<<target<<endl;
return 0;
}