You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
int T;
|
|
|
|
|
int main() {
|
|
|
|
|
// 加快读入
|
|
|
|
|
ios::sync_with_stdio(false), cin.tie(0);
|
|
|
|
|
cin >> T;
|
|
|
|
|
|
|
|
|
|
while (T--) {
|
|
|
|
|
int n, m;
|
|
|
|
|
cin >> m >> n;
|
|
|
|
|
// 对于每个数据集,第一行输出两个整数,分别代表数据集的编号以及
|
|
|
|
|
// 输出中位数的个数(应为数据个数加一的二分之一),数据之间用空格隔开。
|
|
|
|
|
printf("%d %d\n", m, (n + 1) / 2);
|
|
|
|
|
|
|
|
|
|
priority_queue<int, vector<int>, greater<int>> up; // 小顶堆
|
|
|
|
|
priority_queue<int> down; // 默认大顶堆
|
|
|
|
|
|
|
|
|
|
// 对顶堆
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
for (int i = 1; i <= n; i++) {
|
|
|
|
|
int x;
|
|
|
|
|
cin >> x;
|
|
|
|
|
|
|
|
|
|
if (!up.size() || x >= up.top())
|
|
|
|
|
up.push(x);
|
|
|
|
|
else
|
|
|
|
|
down.push(x);
|
|
|
|
|
|
|
|
|
|
if (up.size() > down.size() + 1) down.push(up.top()), up.pop();
|
|
|
|
|
if (down.size() > up.size()) up.push(down.top()), down.pop();
|
|
|
|
|
|
|
|
|
|
// 奇数才输出
|
|
|
|
|
if (i & 1) {
|
|
|
|
|
printf("%d ", up.top());
|
|
|
|
|
if (++cnt % 10 == 0) puts(""); // 题目要求十个一换行
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 最后不足10个,也需要输出一个的换行
|
|
|
|
|
if (cnt % 10) puts("");
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|