求助 3WA 3RE
查看原帖
求助 3WA 3RE
1034295
QuaternaryTree楼主2023/10/4 19:43
#include <iostream>
#include <cstdio>
#include <stack>
using namespace std;
int main()
{
	long long a[10005],n,max=0,x,tot=0;
	stack<int>s;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x==0)
		{
			cin>>x;
			s.push(x);
			if(s.top()>max)
			{
				max=x;
			}
			a[i]=x;
			tot++;
		}
		else if(x==1)
		{
			s.pop();
			a[tot]=0;
			tot--;
			max=0;
			if(s.empty())
			{
				max=0;
			}
			else
			{
				for(int j=1;j<=tot;j++)
				{
					if(a[j]>max)
					{
						max=a[j];
					}
				}
			}
		}
		else if(x==2)
		{
			cout<<max<<endl;
		}
	}
	return 0;
} 
2023/10/4 19:43
加载中...