F.cpp 407 B

12345678910111213141516171819202122
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. int n, q;
  5. cin >> n >> q;
  6. vector<priority_queue<int>> S(n);
  7. while (q--) {
  8. int op, t;
  9. cin >> op >> t;
  10. if (op == 0) {
  11. int x;
  12. cin >> x;
  13. S[t].push(x);
  14. } else if (op == 1) {
  15. if (S[t].size()) cout << S[t].top() << endl;
  16. } else if (op == 2) {
  17. if (S[t].size()) S[t].pop();
  18. }
  19. }
  20. return 0;
  21. }