分析:给你n个操作,1 x :代表在数组中加入元素x,2 :代表删除最小元素,3 :代表输入最大值。删除时,就算我们的数不是最小的也可以,它也不知道,只要不是最大的就行,当数组内的数为0时,就重新初始化最大值,每加入一个数就和最大值判断。
# include <stdio.h>
int main()
{
int i,n,num,t,x,max;
while(scanf("%d",&n)!=EOF)
{
max=-1000000000;
num=0;
while(n--)
{
scanf("%d",&t);
if(t==1)
{
scanf("%d",&x);
num++;
max=x>max?x:max;
}
else if(t==2&&num>0)
{
num--;
if(num==0)
max=-1000000000;
}
else if(t==3)
{
if(num==0)
printf("0\n");
else
printf("%d\n",max);
}
}
}
return 0;
}