提交时间:2023-08-22 16:17:05

运行 ID: 99332

#include <bits/stdc++.h> using namespace std; int a[120]; int main() { while (true) { int op; cin >> op; if (op == 0) break; if (op == 2) { int m = -1; for (int i = 1; i <= 106; i++) { if (a[i]) m = max(m, i); } if (m == -1) cout << 0 << endl; else { cout << a[m] << endl; a[m] = 0; } } else if (op == 3) { int m = 1e9; for (int i = 1; i <= 106; i++) { if (a[i]) m = min(m, i); } if (m == -1) cout << 0 << endl; else { cout << a[m] << endl; a[m] = 0; } } else if (op == 1) { int k, p; cin >> k >> p; a[p] = k; } } return 0; }