请问为什么错了?
查看原帖
请问为什么错了?
556680
NRDI楼主2023/1/11 12:28
#include <bits/stdc++.h>

using namespace std;

int n, w, now, mooo;
priority_queue<int> R;
priority_queue<int, vector<int>, greater<int> > L;

void pus(int x) {
	if (x < L.top() || L.empty()) {
		L.push(x);
		if (L.size() > now) {
			R.push(L.top());
			L.pop();
		}
	}
	else {
		R.push(x);
		if (R.size() > mooo - now) {
			L.push(R.top());
			R.pop();
		}
	}
	return ;
}

int main() {
	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		int x;
		now = max(1, i * w / 100);
		cin >> x;
		mooo = i;
		pus(x);
		cout << L.top() << " ";
	}
	return 0;
}
2023/1/11 12:28
加载中...