题意:
不断的往集合里放数..又有不断的询问集合中第k大的数是什么...
题解:
本来想用treap水一下的...结果WA了...treap应该水得过吧???模板有错~~~汗颜.....那就直接优先队列水把...维护点个数为k的一个大根堆就行了...
Program:
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<time.h>
#include<map>
#include<algorithm>
#define ll long long
#define eps 1e-5
#define oo 1000000007
#define pi acos(-1.0)
#define MAXN 2000005
using namespace std;
struct node
{
int x;
bool operator <(node a) const
{
return a.x<x;
}
}h,p;
priority_queue<node> myqueue;
int main()
{
int m,k;
while (~scanf("%d%d\n",&m,&k))
{
while (!myqueue.empty()) myqueue.pop();
while (m--)
{
char c;
do { c=getchar(); } while (c<'A' || c>'Z');
if (c=='I')
{
int x;
scanf("%d",&x);
h.x=x;
myqueue.push(h);
if (myqueue.size()>k) myqueue.pop();
}else
printf("%d\n",myqueue.top().x);
}
}
return 0;
}