hdu 1908 데이터 구조 물 문제
4510 단어 데이터 구조
/*
* hdu1908/win.cpp
* Created on: 2012-11-2
* Author : ben
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <functional>
#include <numeric>
#include <cctype>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif
int op, a, b;
set<pair<int, int> > S;
while(scanf("%d", &op) == 1 && op > 0) {
if(op == 1) {
scanf("%d%d", &a, &b);
S.insert(make_pair(b, a));
}else if(S.empty()) {
puts("0");
}else if(op == 3) {
printf("%d
", (*S.begin()).second);
S.erase(S.begin());
}else {
set<pair<int, int> >::iterator it = S.end();
it--;
printf("%d
", (*it).second);
S.erase(it);
}
}
return 0;
}