This commit is contained in:
Zengtudor 2024-08-23 22:05:05 +08:00
parent 6bc2d99e25
commit 39c9114206
2 changed files with 40 additions and 2 deletions

View File

@ -1,10 +1,48 @@
#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;
}

View File

@ -1,6 +1,6 @@
add_rules("mode.debug","mode.release")
if is_mode("debug") then
add_cxxflags("-O2")
add_cxxflags("-O2","-DOI")
end
set_languages("c++17")