提交时间:2023-08-22 16:43:32

运行 ID: 99409

#include<bits/stdc++.h> using namespace std; int a[1005]; int main(){ int n, k, p; while(cin >> n && n != 0){ if(n == 1){ cin >> k >> p; a[k] = p; } if(n == 2){ int maxn = 0; for(int i = 1; i <= 1005; i++){ if(a[i] > maxn){ maxn = i; } } cout << maxn << endl; a[maxn] = 0; } if(n == 3){ int minn = 0x3f3f3f3f; for(int i = 1; i <= 1005; i++){ if(a[i] != 0 && a[i] < minn){ minn = i; } } if(minn != 0x3f3f3f3f) cout << minn << endl; else cout << 0 << endl; a[minn] = -1; } } }