#include<cstdio> #include<cstdlib> #include<set> #include<utility> using namespace std; typedef pair<int,int> pii; int main(){ int op, k, p; set<pii> que; for(;;){ scanf("%d", &op); if(op == 0) break; if(op == 1){ scanf("%d %d", &k, &p); que.insert(pii(p, k)); }else if(op == 2){ if(que.size() == 0) puts("0"); else{ set<pii>::iterator get = que.end(); get--; printf("%d\n", get->second); que.erase(*get); } }else{ if(que.size() == 0) puts("0"); else{ set<pii>::iterator get = que.begin(); printf("%d\n", get->second); que.erase(*get); } } } return 0; }
沒有留言:
張貼留言