题意:传送门
题解:一眼看上去,水题啊,写了个排序爆T,写了个map爆空间,一看空间要求1MB,这样一 不能用数组,更不能用STL,用一个抵消算法,遇见一个新的抵消下,抵消到0赋值给它,直到最后,这个题还不能用bits/stdc++.h这个头文件,用C最好了,不然永远差那么一点点。
附上代码:
#include<cstdio>
using namespace std;
int n,t,x,tot;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&x);
if(x==t){
tot++;
}else if(!tot){
t=x;tot=1;
}else{
tot--;
}
}
printf("%d\n",t);
return 0;
}