From 5b1173465a938f04d26f5a9acd03af43916f2117 Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Tue, 11 Nov 2025 18:40:25 +0900 Subject: [PATCH] =?UTF-8?q?[20251111]=20BOJ=20/=20G5=20/=20=EB=AA=A8?= =?UTF-8?q?=EB=8F=85=20/=20=EC=9D=B4=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../11 BOJ \353\252\250\353\217\205.md" | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 "0224LJH/202511/11 BOJ \353\252\250\353\217\205.md" diff --git "a/0224LJH/202511/11 BOJ \353\252\250\353\217\205.md" "b/0224LJH/202511/11 BOJ \353\252\250\353\217\205.md" new file mode 100644 index 00000000..8a83f05a --- /dev/null +++ "b/0224LJH/202511/11 BOJ \353\252\250\353\217\205.md" @@ -0,0 +1,42 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.*; +import java.util.*; + +public class Main { + + static int cnt; + static PriorityQueue pq = new PriorityQueue<>(); + + public static void main (String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + cnt = Integer.parseInt(br.readLine()); + for (int i = 0; i < cnt; i++) { + pq.add(Integer.parseInt(br.readLine())); + } + + int goal = 1; + long hackerCnt = 0; + + while(!pq.isEmpty()) { + if (goal == pq.peek()) { + goal++; + pq.poll(); + } else if (goal > pq.peek()) { + pq.poll(); + } else { + hackerCnt += pq.peek()-goal; + pq.poll(); + goal++; + } + } + + System.out.println(hackerCnt); + + } + +} + +```