全WA求调
  • 板块P1168 中位数
  • 楼主asas111
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/7/28 18:49
  • 上次更新2023/11/3 07:11:03
查看原帖
全WA求调
661096
asas111楼主2023/7/28 18:49

样例过了,下载了数据发现输出一样

#include<bits/stdc++.h>
using namespace std;
int main(){
	priority_queue<int> p;
	priority_queue<int,vector<int>,greater<int> > q;
	int n,x,y,m;
	cin>>n>>x;
	p.push(x);
	for(int i=2;i<=n;i+=2){
		m=p.top();
		cout<<m<<endl;
		cin>>x>>y;
		if(x>y)swap(x,y);
		if(m<=x){
			q.push(x);
			q.push(y);
			p.push(q.top());
			q.pop();
		}
		else if(y<=m){
			p.push(x);
			p.push(y);
			q.push(p.top());
			p.pop();
		}
		else{
			p.push(x);
			q.push(y);
		}
	}
	cout<<p.top();
	return 0;
}
2023/7/28 18:49
加载中...