ans

zhangjinghao 2024-01-13 14:49:17 4 返回题目

#include<bits/stdc++.h>
using namespace std;
int n,k,p,op,last;
priority_queue<int> q2;
priority_queue<int,vector<int>,greater<int>> q1;
int main(){
	cin>>n>>k>>p;
	for(int i=1;i<=n;i++){
		cin>>op;
		if(op==1){
			int x;
			cin>>x;
			if(p==1){
				x=x^last;
			}
			q1.push(x);
			if(q1.size()>k){
				int t=q1.top();
				q1.pop();
				q2.push(t);
			}
		}else{
			last=q1.top();
			q1.pop();
			if(!q2.empty()){
				int t=q2.top();
				q1.push(t);
				q2.pop();
			}
			cout<<last<<endl;
		}
	}
	return 0;
}
{{ vote && vote.total.up }}