皮一下很开心

piyixiahenkaixin 2020-11-14 11:07:47 5 返回题目

#include<bits/stdc++.h> using namespace std; int f[1010],head=0,z[1010]; int main() { freopen("train.in","r",stdin); freopen("train.out","w",stdout); int n; cin>>n; for(int i=1;i<=n;++i) scanf("%d",&f[i]); for(int h=1,k=1;h<=n;++h)
{ while(k<=f[h]) { z[++head]=k;++k; } if(z[head]==f[h]) { --head; } else { cout<<"NO"; return 0; } } cout<<"YES"; fclose(stdin);fclose(stdout); return 0; }

{{ vote && vote.total.up }}