2 solutions
-
0
#include<bits/stdc++.h> using namespace std; int a[1010]; int main() { int n; cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; stack<int> c; int i=1; for(int j=1;j<=n;j++) { c.push(j); while(c.size()&&c.top()==a[i]) { c.pop(); i++; } } if(c.size()==0)cout<<"YES"; else cout<<"NO"; return 0; }
- 1
Information
- ID
- 174
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- # Submissions
- 17
- Accepted
- 6
- Uploaded By