- 题解
OJ #yc2501. 勇者与恶龙
- @ 2026-2-27 18:04:30
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long n,res,cnt,x;
cin>>n>>x;
res=x;cnt=1;
n--;
while(n--){
cin>>x;
if(res==x){
cnt++;
}
else {
cnt--;
}
if(cnt<=0){
res=x;cnt=1;
}
}
cout<<res;
}
0 条评论
目前还没有评论...