#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stack>
using namespace std;
const int maxn=10010;
const int N=10;
int target[maxn];
int main(){
int n;
while(scanf("%d",&n)!=EOF){
stack<int> s;
for(int i=1;i<=n;i++)
scanf("%d",&target[i]);
int ok=1;
int A=1,B=1;
while(B<=n){
if(A==target[B]) {A++,B++;}
else if(!s.empty()&&s.top()==target[B]) { s.pop(); B++; }
else if(A<=n) s.push(A++);
else { ok=0;break; }
}
printf("%s\n",ok?"Yes":"No");
}
return 0;
}
uva 514
猜你喜欢
转载自blog.csdn.net/qq_924485343/article/details/104257139
今日推荐
周排行