HDU 5349 MZL's simple problem(水题)

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int inf=-1e9+10;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int x,y;
        int Max=inf;
        int cnt=0;
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&x);
            if(x==1)
            {
                cnt++;
                scanf("%d",&y);
                Max=max(Max,y);
            }
            else if(x==2)
            {
                if(cnt>0)
                {
                    cnt--;
                    if(cnt==0)
                        Max=inf;
                }
            }
            else
            {
                if(cnt==0)
                    printf("0\n");
                else
                    printf("%d\n",Max);
            }
        }
    }
    return 0;
}

你可能感兴趣的:(HDU 5349 MZL's simple problem(水题))