Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int arr[1010];
- int main()
- {
- //freopen("t.txt","w",stdout);
- int n;
- while(cin>>n && n)
- {
- while(cin>>arr[0] && arr[0])
- {
- for(int i=1; i<n; i++)
- {
- cin>>arr[i];
- }
- stack<int>st;
- int cnt =0;
- for(int i=1; i<=n; i++)
- {
- st.push(i);
- while(st.size()>0 && arr[cnt]==st.top())
- {
- cnt++;
- st.pop();
- }
- }
- if(st.size()==0)
- cout<<"Yes"<<endl;
- else
- cout<<"No"<<endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement