From 157286d0ee828327bad8596ed8eba073f6683a21 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Thu, 4 Sep 2025 15:30:35 +0900 Subject: [PATCH] =?UTF-8?q?[20250904]=20PGM=20/=20LV3=20/=20[1=EC=B0=A8]?= =?UTF-8?q?=20=EC=85=94=ED=8B=80=EB=B2=84=EC=8A=A4=20/=20=EA=B9=80?= =?UTF-8?q?=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...24\355\213\200\353\262\204\354\212\244.md" | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 "suyeun84/202509/04 PGM LV3 [1\354\260\250] \354\205\224\355\213\200\353\262\204\354\212\244.md" diff --git "a/suyeun84/202509/04 PGM LV3 [1\354\260\250] \354\205\224\355\213\200\353\262\204\354\212\244.md" "b/suyeun84/202509/04 PGM LV3 [1\354\260\250] \354\205\224\355\213\200\353\262\204\354\212\244.md" new file mode 100644 index 00000000..bd833962 --- /dev/null +++ "b/suyeun84/202509/04 PGM LV3 [1\354\260\250] \354\205\224\355\213\200\353\262\204\354\212\244.md" @@ -0,0 +1,42 @@ +```java +import java.util.*; +class Solution { + public String solution(int n, int t, int m, String[] timetable) { + int answer = 0; + PriorityQueue pq = new PriorityQueue<>(); + // 크루 도착 시간 + for (String time : timetable) pq.add(convertToTime(time)); + + int departTime = 9*60; + List> bus = new ArrayList<>(); + // 각 버스에 타는 크루 저장 + for (int i = 0; i < n; i++) bus.add(new ArrayList<>()); + + for (int i = 0; i < n; i++) { + while (!pq.isEmpty()) { + int crew = pq.poll(); + if (bus.get(i).size() < m && crew <= departTime) { + bus.get(i).add(crew); + answer = crew - 1; + } else { + pq.add(crew); + break; + } + } + departTime += t; + } + + if (bus.get(n-1).size() < m) answer = departTime - t; + return convertToString(answer); + } + + static int convertToTime(String s) { + String[] a = s.split(":"); + return Integer.parseInt(a[0]) * 60 + Integer.parseInt(a[1]); + } + + static String convertToString(int time) { + return String.format("%02d:%02d", time / 60, time % 60); + } +} +```