From c67ebc6deb118a6650d3dc6b6bf176d117e5be57 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Wed, 3 Sep 2025 21:11:23 +0900 Subject: [PATCH] =?UTF-8?q?[20250903]=20PGM=20/=20LV3=20/=20=EB=94=94?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20/?= =?UTF-8?q?=20=EA=B9=80=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\355\212\270\353\241\244\353\237\254.md" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "suyeun84/202509/03 PGM LV3 \353\224\224\354\212\244\355\201\254 \354\273\250\355\212\270\353\241\244\353\237\254.md" diff --git "a/suyeun84/202509/03 PGM LV3 \353\224\224\354\212\244\355\201\254 \354\273\250\355\212\270\353\241\244\353\237\254.md" "b/suyeun84/202509/03 PGM LV3 \353\224\224\354\212\244\355\201\254 \354\273\250\355\212\270\353\241\244\353\237\254.md" new file mode 100644 index 00000000..b246e634 --- /dev/null +++ "b/suyeun84/202509/03 PGM LV3 \353\224\224\354\212\244\355\201\254 \354\273\250\355\212\270\353\241\244\353\237\254.md" @@ -0,0 +1,29 @@ + '''java +import java.util.*; +class Solution { + public int solution(int[][] jobs) { + int answer = 0; + jobs.add(new int[]{1, 1}); + Arrays.sort(jobs, (o1, o2) -> Integer.compare(o1[0], o2[0])); + PriorityQueue pq = new PriorityQueue<>((o1, o2) -> Integer.compare(o1[0], o2[0])); + int curr_time = 0; + int curr_idx = 0; + int cnt = 0; + while (cnt < jobs.length) { + while (curr_idx < jobs.length && jobs[curr_idx][0] <= curr_time) { + pq.add(new int[]{jobs[curr_idx][1], jobs[curr_idx][0]}); //(걸리는 시간, 시작 시간) + curr_idx += 1; + } + if (!pq.isEmpty()) { + int[] time = pq.poll(); + cnt += 1; + answer += (curr_time - time[1] + time[0]); + curr_time += time[0]; + } else { + curr_time += 1; + } + } + return answer / jobs.length; + } +} +```