ProgramAlgTrain/20240823/十四届蓝桥比赛/主要成分.cpp
2024-08-23 22:05:05 +08:00

48 lines
805 B
C++

#include<bits/stdc++.h>
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;
}