还是利用优先队列乱搞23333//为什么foj不能用万能头文件orz
ACcode:
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#define maxn 1000010
#define ll long long
using namespace std;
char s[11];
ll a[maxn],tot,num;
struct cmp{
bool operator()(const int x,const int y){
return a[x]<a[y];
}
};
int main(){
int n;
while(~scanf("%d",&n)){
scanf("%s",s);
num=tot=0;
priority_queue<int,vector<int>,cmp>dp;
while(scanf("%s",s)&&s[0]!='E'){
if(s[0]=='C'){
int v;
scanf("%s%lld",s,&a[++tot]);
dp.push(tot);
}
else if(s[0]=='Q'){
if(dp.empty()){
puts("-1");
continue;
}
else{
while(dp.top()<=num&&!dp.empty())dp.pop();
if(dp.empty())puts("-1");
else printf("%lld\n",a[dp.top()]);
}
}
else if(s[0]=='G')
num++;
}
}
return 0;
}
Problem 1894 志愿者选拔
Accept: 1805 Submit: 5599
Time Limit: 1500 mSec Memory Limit : 32768 KB
Problem Description
Input
输入 | 含义 | |
1 | C NAME RP_VALUE | 名字为NAME的人品值为RP_VALUE的同学加入面试队伍。(名字长度不大于5,0 <= RP_VALUE <= 1,000,000,000) |
2 | G | 排在面试队伍最前面的同学面试结束离开考场。 |
3 | Q | 主面试官John想知道当前正在接受面试的队伍中人品最高的值是多少。 |
Output
Sample Input
2
START
C Tiny 1000000000
C Lina 0
Q
G
Q
END
START
Q
C ccQ 200
C cxw 100
Q
G
Q
C wzc 500
Q
END
Sample Output
1000000000
0
-1
200
100
500