标签:整数 dia int tchar namespace turn printf cstring 动态
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
inline int read(){
int x=0,o=1;char ch=getchar();
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')o=-1,ch=getchar();
while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
return x*o;
}
priority_queue<int>q;//大根堆
priority_queue<int,vector<int>,greater<int> >Q;//小根堆
int main(){
int n=read();//多组数据
for(int o=1;o<=n;++o){
while(q.size())q.pop();
while(Q.size())Q.pop();//清空操作
int num=read(),m=read(),sum=0;
printf("%d %d\n",num,(m+1)/2);
for(int i=1;i<=m;++i){
int a=read();
if(i==1||a>=Q.top()){
Q.push(a);
if(Q.size()>((i+1)/2)){
q.push(Q.top());
Q.pop();
}
}
else{
q.push(a);
if(q.size()>(i/2)){
Q.push(q.top());
q.pop();
}
}
if(i&1){
printf("%d ",Q.top());
++sum;if(sum%10==0)puts("");
}
}
puts("");
}
return 0;
}
标签:整数 dia int tchar namespace turn printf cstring 动态
原文地址:https://www.cnblogs.com/PPXppx/p/11229505.html