ProgramAlgTrain/20240823/十四届蓝桥比赛/主要成分.cpp
2024-09-17 18:55:15 +08:00

49 lines
814 B
C++

#include<iostream>
#include<map>
using namespace std;
typedef long long ll;
#ifdef OI
#define PV(v){cout<<#v<<" : "<<(v)<<endl;}
#else
#define PV(v)
#endif
int n;
map<ll,int> m;
ll readint();
int main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
n=readint();
for(int i=1;i<=n;i++){
m[readint()]++;
}
int max_m=INT_MIN;
ll max_dir = -1;
for(auto i :m){
if(max_m<i.second){
max_m=i.second;
max_dir=i.first;
}
}
if(max_m>n/2){
cout<<max_dir<<endl;
}else{
cout<<"No"<<endl;
}
}
ll readint(){
int x=0,w=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-')w=-1;
ch=getchar();
}
while(isdigit(ch)){
x=x*10+(ch-'0');
ch=getchar();
}
return x*w;
}