提交时间:2023-08-22 16:31:09
运行 ID: 99399
#include <bits/stdc++.h> using namespace std; struct node{ int v,id; }; bool cmp(node x, node y) { if(x.v==y.v) return x.id < y.id; return x.v > y.v; } node a[1145141]; signed main() { int op,k,p,cnt=0; while(cin >> op) { if(op==0)exit(0); if(op==1) { cin >> k >> p; cnt++; a[cnt].id=k; a[cnt].v=p; } if(op==2) { if(cnt==0) { cout << 0 << endl; continue; } cout << a[1].id << endl; swap(a[1],a[cnt]); a[cnt] = (node){0,0}; cnt--; } if(op==3) { if(cnt==0) { cout << 0 << endl; continue; } cout << a[cnt].id << endl; a[cnt] = (node){0,0}; cnt--; } sort(a+1,a+cnt+1,cmp); } return 0; }