对栈的使用
stack sta;
sta.push();
sta.top();
sta.pop();
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
using namespace std;
int t[1005];
int main()
{
// freopen("E:\\input.txt","r",stdin);
int case1=0;
for(;;)
{
if(case1) printf("\n");
case1++;
int n;
scanf("%d",&n);
if(n==0) break;
stack<int> sta;
for(;;)
{
int a;
scanf("%d",&a);
if(a==0) break;
else t[0]=a;
for(int i=1;i<n;i++)
scanf("%d",&t[i]);
int temp=1,flag=0;
for(int i=0;i<n;i++)
{
while(t[i]>=temp) {sta.push(temp);temp++;}
if(!sta.empty())
{
int k=sta.top();
sta.pop();
if(k!=t[i])
flag=1;
}
if(flag) break;
}
if(flag) printf("No\n");
else printf("Yes\n");
}
}
return 0;
}