悬关,4、5超市
  • 板块P1165 日志分析
  • 楼主aleavf
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/4/23 20:08
  • 上次更新2024/4/23 21:54:26
查看原帖
悬关,4、5超市
1242018
aleavf楼主2024/4/23 20:08
#include<bits/stdc++.h>
using namespace std;
stack<int>a;
long long b[20000000];
int main(){
	int c,x,y,max=0,r=0;
	cin>>c;
	for(int i=0;i<c;i++){
		ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
		cin>>x;
		if(x==0){
			cin>>y;
			a.push(y);
			b[r]=y;
			r++;
		}
		if(x==1){
			a.pop();
			r--;
			b[r]=0;
		}
		if(x==2){
			if(a.empty()){
			cout<<0<<endl;
			continue;	
			}
			for(int j=0;j<=r;j++){
				if(b[j]>=max){
					max=b[j];
				}
			}
			cout<<max<<endl;
			max=0;
		}
	}
}
2024/4/23 20:08
加载中...