• + 0 comments

    in java i used a TreeSet

    public static void main(String[] args) { Scanner s = new Scanner(System.in);

        int q = s.nextInt();
        Set<Integer> heap = new TreeSet<>();
        for (int i = 0; i<q;i++) {
            int qt = s.nextInt();
            switch (qt) {
                case 1:
                    heap.add(s.nextInt());
                    break;
                case 2:
                    heap.remove(s.nextInt());
                    break;
                case 3:
                    System.out.println( heap.stream().findFirst().get() );
                    break;
            }
        }
                        s.close();
    }
    
    
    
    
        }
    
        s.close();
    }