Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class Solution {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int t = sc.nextInt();
- for (int a = 1; a <= t; a++) {
- PriorityQueue<Integer> q = new PriorityQueue<Integer>();
- System.out.print("#" + a + " ");
- int n = sc.nextInt();
- for (int b = 0; b < n; b++) {
- int command = sc.nextInt();
- if (command == 1) {
- int number = sc.nextInt();
- q.add(-number);
- } else {
- if (q.isEmpty()) {
- System.out.print(-1 + " ");
- } else {
- int print = q.poll();
- System.out.print(-print + " ");
- }
- }
- }
- System.out.println();
- }
- sc.close();
- }
- }
Add Comment
Please, Sign In to add comment