T4求调!!!!!1

^^^cpp
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int h[N],q[N],a[N];
int main(){
int t;
cin >> t;
while(t–){
int mx=0;
int n;
cin >> n;
for(int i=1;i<=n;++i){
cin >> a[i];
mx=max(mx,a[i]);
}
int top=0;
memset(q,0,sizeof(q));
memset(h,0,sizeof(h));
for(int i=1;i<=n;++i){
q[++top]=a[i];
if(top>1&&q[top]==q[top-1]){
if(q[top]<h[top-1]){
continue;
}
top-=2,h[top]=q[top+1];
h[top+1]=0;h[top+2]=0;
}
}
if(top==0||(top==1&&q[top]==mx)) cout << “YES”;
else cout << “nO”;
}

return 0;

}

3 个赞

hello,同学,需要描述你的题目什么,思路是什么,出现的问题是什么,已经做了什么尝试,并且需要把问题发在对应的类别中哦

3 个赞