1 条题解
-
0Guest LV 0
-
0
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> int n,tot,top,a[1005],stack[1005]; using namespace std; int main(void) { //freopen("test.in","r",stdin); //freopen("test.input","w",stdinput); cin>>n; for(int i=1;i<=n;++i) { cin>>a[i]; } for(int i=1;i<=n;++i) { if(a[i]<=tot) { if(a[i]==stack[top]) { --top; } else { cout<<"NO"<<endl; return 0; } } else { for(int j=tot+1;j<=a[i];++j) { stack[++top]=j; } --top; tot=a[i]; } } cout<<"YES"<<endl; return 0; }
- 1