문제
 
제한 사항 및 입출력
 
문제풀이
import java.util.*;
class Solution {
    public int[] solution(String[] operations) {
        int[] answer = new int[2];
        PriorityQueue<Integer> pq1 = new PriorityQueue<>();
        PriorityQueue<Integer> pq2 = new PriorityQueue<>(Collections.reverseOrder());
        
        String[] tmp;
        for(int i = 0 ; i < operations.length;i++){
            tmp = operations[i].split(" ");
            if(pq1.size()==0 && tmp[0].equals("D"))continue;
            if(tmp[0].equals("I")){
                pq1.add(Integer.parseInt(tmp[1]));
                pq2.add(Integer.parseInt(tmp[1]));
            }else if(tmp[0].equals("D")&&tmp[1].equals("1")){
                int max = pq2.poll();
                pq1.remove(max);
            }else if(tmp[0].equals("D")&&tmp[1].equals("-1")){
                int min = pq1.poll();
                pq2.remove(min);
            }
        }
        if(pq1.size()>0){
            answer[0]=pq2.poll();
            answer[1]=pq1.poll();
        }
        
        return answer;
    }
}
 
※ 내 생각
우선 순위 큐를 2개 이용하여 문제풀이를 진행했습니다.
오름차순을 진행하는 큐
내림차순을 진행하는 큐
2개의 큐를 만들고 상황에 따라서 각각을 삭제했습니다.