一半 AC 一半TLE
查看原帖
一半 AC 一半TLE
673489
XMLC7737楼主2023/4/9 10:59
#include <stdio.h>
#include <algorithm>
using namespace std;

long long num, o, x,top;
int cnm[200009];
int push(int h)
{
    cnm[top++] = h;
}
void pop()
{
    if (top != 0)
    {
        cnm[top] = 0;
        top--;
    }
}
int main()
{
    scanf("%lld", &num);
    for (int i = 1; i <= num; i++)
    {
        scanf("%lld", &o);
        if (o == 0)
        {
            scanf("%lld", &x);
            push(x);
        }
        else if (o == 1)
            pop();
        else if (o == 2)
        {
            if (top != 0)
            {
                int maxx = -1;
                for (int i = 0; i < top; i++)
                {
                    maxx = max(maxx, cnm[i]);
                }
                if (maxx != -1)
                    printf("%lld\n", maxx);
            }
            else
                printf("0\n");
        }
    }
}

对了一半

心态爆炸

2023/4/9 10:59
加载中...