社区讨论

爆零!求调!!!哼,哼,哼啊啊啊啊啊啊!

P1165日志分析参与者 1已保存回复 1

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
1 条
当前快照
1 份
快照标识符
@m2os0v0d
此快照首次捕获于
2024/10/25 21:37
去年
此快照最后确认于
2025/11/04 16:09
4 个月前
查看原帖
三个wa,三个tle
CPP
#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;
}

回复

1 条回复,欢迎继续交流。

正在加载回复...