爆零!求调!!!哼,哼,哼啊啊啊啊啊啊!
  • 板块P1165 日志分析
  • 楼主wsllk22
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/10/25 21:36
  • 上次更新2024/10/25 22:07:28
查看原帖
爆零!求调!!!哼,哼,哼啊啊啊啊啊啊!
1320251
wsllk22楼主2024/10/25 21:36

三个wa,三个tle

#include<bits/stdc++.h>
using namespace std;
int n,t;
std::stack<int>souxun;
std::stack<int>cunchu;
void chongzai(){
	for(;!souxun.empty();){
		cunchu.push(souxun.top());
		souxun.pop();
	}
}
int find_max(){
	int a=1;
	for(;!cunchu.empty();){
		if(cunchu.top()>=a)a=cunchu.top();
		souxun.push(cunchu.top());
		cunchu.pop();
	}
	chongzai();
	return a;
}
int main(){
	cin>>n;
	while(n--){
		cin>>t;
		if(t==1){
			if(!cunchu.empty())cunchu.pop();
		}
		if(t==2){
			if(cunchu.empty()){
				cout<<"0";
			}else cout<<find_max();
		}
		if(t==0){
			cin>>t;
			cunchu.push(t);
		}
	}
	return 0;
}

2024/10/25 21:36
加载中...