import java.util.*; public class Solution { PriorityQueue minHeap = new PriorityQueue<>(); PriorityQueue maxHeap = new PriorityQueue<>(new Comparator(){ @Override public int compare(Integer o1,Integer o2){ return o2 - o1; } }); int count = 0;

public void Insert(Integer num) {
     if(count % 2 == 0){
        //已经偶数个 放到
        maxHeap.offer(num);
        int temp = maxHeap.poll();
        minHeap.offer(temp);
    }else{
        minHeap.offer(num);
        int temp = minHeap.poll();
        maxHeap.offer(temp);
    }
    count ++;

}

public Double GetMedian() {
     if(count % 2 == 0){
        return  new Double(minHeap.peek() + maxHeap.peek() ) / 2;
    }else{
        return new Double(minHeap.peek());
    }
}

}