提交时间:2023-08-22 16:27:19
运行 ID: 99389
#include<bits/stdc++.h> //#define int long long using namespace std; vector <pair <int,int> > vec; namespace Fast{ inline int fr(){ register int x = 0,f = 1; static char c = getchar(); while (c < '0' || c > '9'){ if (c == '-'){ f = -1; } c = getchar(); } while (c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void fw(int x){ if (x < 0){ x = -x; putchar('-'); } if (x > 9){ fw(x / 10); } putchar(x % 10 + 48); } } using namespace Fast; int a[114514],b[114514]; signed main(){ memset(b,0x3f3f3f3f,sizeof(b)); int n,o = 0; while (cin>>n){ if (n == 0){ break; } if (n == 1){ int x,y; x = fr(),y = fr(); o++; a[o] = x; b[o] = y; } else if (n == 2){ int id = 0,maxn = 0; for (int i = 1;i <= o;i++){ if (b[i] >= 0x3f3f3f3f){ continue; } if (b[i] > maxn){ maxn = b[i]; id = i; } } cout<<a[id]<<'\n'; b[id] = 0x3f3f3f3f; } else if (n == 3){ int id = 0,maxn = 1919810; for (int i = 1;i <= o;i++){ if (b[i] >= 0x3f3f3f3f){ continue; } if (b[i] < maxn){ maxn = b[i]; id = i; } } cout<<a[id]<<'\n'; b[id] = 0x3f3f3f3f; } } return 0; }