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(x!=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++;}
- else if(k!=m){
- pilha.push(k);
- m++;
- }
- else if(pilha.top()==m){
- pilha.pop();
- m++;
- }
- else if(i==m){
- if(pilha.size()==0){printf("yes\n");}
- else if(pilha.size()!=0){printf("no\n");}
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement