Guest User

Untitled

a guest
Mar 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class Solution {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6. int t = sc.nextInt();
  7. for (int a = 1; a <= t; a++) {
  8. PriorityQueue<Integer> q = new PriorityQueue<Integer>();
  9. System.out.print("#" + a + " ");
  10. int n = sc.nextInt();
  11. for (int b = 0; b < n; b++) {
  12. int command = sc.nextInt();
  13. if (command == 1) {
  14. int number = sc.nextInt();
  15. q.add(-number);
  16. } else {
  17. if (q.isEmpty()) {
  18. System.out.print(-1 + " ");
  19. } else {
  20. int print = q.poll();
  21. System.out.print(-print + " ");
  22. }
  23. }
  24. }
  25. System.out.println();
  26. }
  27. sc.close();
  28. }
  29. }
Add Comment
Please, Sign In to add comment