View Code
1 #include2 #include 3 using namespace std ; 4 int main() 5 { 6 int a[1005] ; 7 int n ; 8 while(cin>>n,n!=0) 9 {10 while(cin>>a[0],a[0])11 {12 for(int i=1; i >a[i] ;14 stack s ;15 int num = 0 ;16 for(int i=1; i<=n; i++)17 {18 s.push(i) ;19 while(!s.empty()&&s.top()==a[num])20 {21 s.pop() ;22 num++ ;23 }24 }25 if(s.empty())26 cout<<"Yes"<