Advertisement
hkshakib

Untitled

Mar 17th, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int arr[1010];
  4. int main()
  5. {
  6. //freopen("t.txt","w",stdout);
  7. int n;
  8. while(cin>>n && n)
  9. {
  10. while(cin>>arr[0] && arr[0])
  11. {
  12. for(int i=1; i<n; i++)
  13. {
  14. cin>>arr[i];
  15. }
  16. stack<int>st;
  17. int cnt =0;
  18. for(int i=1; i<=n; i++)
  19. {
  20. st.push(i);
  21. while(st.size()>0 && arr[cnt]==st.top())
  22. {
  23. cnt++;
  24. st.pop();
  25. }
  26. }
  27. if(st.size()==0)
  28. cout<<"Yes"<<endl;
  29. else
  30. cout<<"No"<<endl;
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement