#include<iostream> #include<string> #include<algorithm> #include<vector> #include<stack> using namespace std; int main() { int n; cin>>n; vector<int>a(n); for(int i=0; i<n; i++) cin>>a[i]; stack<int>s; bool f=1; int cur=1; for(int i=0; i<n; i++) { while((s.empty())||(s.top()!=a[i]&&cur<=n)) { s.push(cur); cur++; } if(s.empty()||s.top()!=a[i]) { f=0; break; } else { s.pop(); } } if(f) cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:802 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:1227 |
C二级辅导-同因查找 (C++代码)(42的倍数,,所以直接递加42输出)浏览:1092 |
K-进制数 (C++代码)浏览:850 |
简单的a+b (C语言代码)浏览:623 |
震宇大神的杀毒软件 (C语言代码)浏览:1240 |
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C++代码)(手动优化一下计算)浏览:1277 |
简单的a+b (C语言代码)浏览:703 |
【数组的距离】 (C语言代码)浏览:728 |
C语言训练-求PI* (C语言代码)浏览:613 |