hdu 4006
#include<stdio.h>
#include<queue>
#include<iostream>
using namespace std;
struct node {
int num;
friend bool operator<(node a,node b) {
return a.num>b.num;
}
};
int main() {
int count,n,k,i;
char s[3];
while(scanf("%d%d",&n,&k)!=EOF) {
priority_queue<node>q;
node p;
count=0;
while(n--) {
scanf("%s",s);
if(s[0]=='I') {
scanf("%d",&i);
p.num=i;
count++;
if(count<=k)
q.push(p);
else {
if(i>q.top().num) {
q.pop();
q.push(p);
}
}
}
else
printf("%d\n",q.top().num);
}
}
return 0;
}
#include<queue>
#include<iostream>
using namespace std;
struct node {
int num;
friend bool operator<(node a,node b) {
return a.num>b.num;
}
};
int main() {
int count,n,k,i;
char s[3];
while(scanf("%d%d",&n,&k)!=EOF) {
priority_queue<node>q;
node p;
count=0;
while(n--) {
scanf("%s",s);
if(s[0]=='I') {
scanf("%d",&i);
p.num=i;
count++;
if(count<=k)
q.push(p);
else {
if(i>q.top().num) {
q.pop();
q.push(p);
}
}
}
else
printf("%d\n",q.top().num);
}
}
return 0;
}