Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int x;
- while(1)
- {
- int ok=0;
- scanf("%d", &x);
- for(int i=1; i<=x; i++)
- {
- int k;
- scanf("%d", &k);
- int m=1;
- stack<int>pilha;
- if(k==m)
- {
- m++;
- ok=1;
- }
- else if(k!=m)
- {
- pilha.push(k);
- m++;
- ok=1;
- }
- else if(pilha.size()!=0 && pilha.top()==m)
- {
- pilha.pop();
- m++;
- ok=1;
- }
- else if(i==m)
- {
- if(pilha.size()==0)
- {
- printf("yes\n");
- ok=0;
- }
- else if(pilha.size()!=0)
- {
- printf("no\n");
- ok=0;
- }
- }
- if(ok=0)break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement