diff --git "a/LiiNi-coder/202507/30 BOJ \354\235\264\354\244\221 \354\232\260\354\204\240\354\210\234\354\234\204 \355\201\220.md" "b/LiiNi-coder/202507/30 BOJ \354\235\264\354\244\221 \354\232\260\354\204\240\354\210\234\354\234\204 \355\201\220.md" new file mode 100644 index 00000000..03bac806 --- /dev/null +++ "b/LiiNi-coder/202507/30 BOJ \354\235\264\354\244\221 \354\232\260\354\204\240\354\210\234\354\234\204 \355\201\220.md" @@ -0,0 +1,43 @@ +```java +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.StringTokenizer; +import java.util.TreeMap; + +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int T = Integer.parseInt(br.readLine()); + + for(int t = 0; t map = new TreeMap<>(); + + for (int i = 0; i < K; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + String command = st.nextToken(); + int value = Integer.parseInt(st.nextToken()); + + if (command.equals("I")) { + map.put(value, map.getOrDefault(value, 0) + 1); + } else if (command.equals("D")) { + if (map.isEmpty()) + continue; + int key = (value == 1) ? map.lastKey() : map.firstKey(); + int count = map.get(key); + if (count == 1) { + map.remove(key); + } else { + map.put(key, count - 1); + } + } + } + if (map.isEmpty()) { + System.out.println("EMPTY"); + } else { + System.out.println(map.lastKey() + " " + map.firstKey()); + } + } + } +} +```