输出不对
查看原帖
输出不对
677581
_Glassy_Sky_楼主2023/1/11 21:52
#include<bits/stdc++.h>
#include<queue>
using namespace std;
priority_queue<int> qmax;
priority_queue<int, vector<int>, greater<int> > qmin;
int main()
{
	int n, x, y; 
	cin >> n >> x;
	qmin.push(x);
	for(int i = 3; i <= n; i += 2)
	{
		cin >> x >> y;
		if(x > y)
			swap(x, y);
		qmin.push(x);
		qmax.push(y);
		if(qmin.top() > qmax.top())
		{
			int a = qmin.top(); qmin.pop();
			int b = qmax.top(); qmax.pop();
			qmin.push(b);
			qmax.push(a);
		}
		cout << qmin.top() << "\n";
	}
	return 0;
}
2023/1/11 21:52
加载中...