WA求助
查看原帖
WA求助
799098
chengzihan620楼主2023/11/28 19:46
#include<bits/stdc++.h>
using namespace std;
inline int read(){int x=0,f=1;char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=(x<<3)+(x<<1)+c-'0';c=getchar();}return x*f;}
void write(int x){if(x<0){x=-x;putchar('-');}
if(x){write(x/10);putchar(x%10+'0');}}

priority_queue<int,vector<int>,less<int> >q;
//大根堆(栈)
int s[200001];

int main(){
	int n=read(),i=1;
	q.push(0);
	while(n--){
		int op=read();
		if(op==0){
			s[i]=read();
			q.push(s[i++]);
		}
		if(op==1){
     //若出栈的不是最大值,则不必出栈
			if(q.top()==s[i]){
				q.pop();
				i--;
			}
		}
		if(op==2){
			cout<<q.top()<<endl;
		}
	}
	return 0;
}
2023/11/28 19:46
加载中...