From 39532020b818ff4df157453dd3f293a732f548de Mon Sep 17 00:00:00 2001 From: Donew <47556347+03do-new30@users.noreply.github.com> Date: Sun, 20 Jul 2025 12:44:40 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[20250720]=20BOJ=20/=20G4=20/=20=EC=9E=91?= =?UTF-8?q?=EC=97=85=20/=20=EC=8B=A0=EB=8F=99=EC=9C=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ G4 2056 \354\236\221\354\227\205.md" | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 "03do-new30/202507/BOJ G4 2056 \354\236\221\354\227\205.md" diff --git "a/03do-new30/202507/BOJ G4 2056 \354\236\221\354\227\205.md" "b/03do-new30/202507/BOJ G4 2056 \354\236\221\354\227\205.md" new file mode 100644 index 00000000..e4c5003e --- /dev/null +++ "b/03do-new30/202507/BOJ G4 2056 \354\236\221\354\227\205.md" @@ -0,0 +1,63 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + static int N; + static int[] indegree; // 차수 저장 + static int[] time; // 시간 저장 + static List[] adjList; // 인접 리스트 + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + indegree = new int[N+1]; + time = new int[N+1]; + adjList = new List[N+1]; + for (int i = 1; i <= N; i++) { + adjList[i] = new ArrayList<>(); + } + + for (int i = 1; i <= N; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + time[i] = Integer.parseInt(st.nextToken()); + + int cnt = Integer.parseInt(st.nextToken()); + for (int j = 0; j < cnt; j++) { + int prevId = Integer.parseInt(st.nextToken()); + adjList[prevId].add(i); + ++indegree[i]; + } + } + int ans = topologicalSort(); + System.out.println(ans); + br.close(); + } + + private static int topologicalSort() { + + Queue q = new ArrayDeque<>(); + int[] visitTime = new int[N+1]; + + for (int i = 1; i <= N; i++) { + visitTime[i] = time[i]; + if (indegree[i] == 0) q.offer(i); + } + + while (!q.isEmpty()) { + int current = q.poll(); + for (int next : adjList[current]) { + visitTime[next] = Math.max(visitTime[next], visitTime[current] + time[next]); + if (--indegree[next] == 0) { + q.offer(next); + } + } + } + + int ret = 0; + for (int i = 1; i <= N; i++) { + ret = Math.max(ret, visitTime[i]); + } + return ret; + } +} +``` From a6bc2052a0c2a0b816ae05a35e842e9e07ee5e6b Mon Sep 17 00:00:00 2001 From: Donew <47556347+03do-new30@users.noreply.github.com> Date: Sun, 20 Jul 2025 12:44:58 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Rename=20BOJ=20G4=202056=20=EC=9E=91?= =?UTF-8?q?=EC=97=85.md=20to=2020=20BOJ=20G4=202056=20=EC=9E=91=EC=97=85.m?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../202507/20 BOJ G4 2056 \354\236\221\354\227\205.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "03do-new30/202507/BOJ G4 2056 \354\236\221\354\227\205.md" => "03do-new30/202507/20 BOJ G4 2056 \354\236\221\354\227\205.md" (100%) diff --git "a/03do-new30/202507/BOJ G4 2056 \354\236\221\354\227\205.md" "b/03do-new30/202507/20 BOJ G4 2056 \354\236\221\354\227\205.md" similarity index 100% rename from "03do-new30/202507/BOJ G4 2056 \354\236\221\354\227\205.md" rename to "03do-new30/202507/20 BOJ G4 2056 \354\236\221\354\227\205.md" From 9e2d7fa03b61330c5167ddf630971d49fccbdd1a Mon Sep 17 00:00:00 2001 From: Donew <47556347+03do-new30@users.noreply.github.com> Date: Sun, 20 Jul 2025 12:46:14 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[20250720]=20BOJ=20/=20G4=20/=20=EC=9E=91?= =?UTF-8?q?=EC=97=85=20/=20=EC=8B=A0=EB=8F=99=EC=9C=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../202507/20 BOJ G4 \354\236\221\354\227\205.md" | 1 + 1 file changed, 1 insertion(+) rename "03do-new30/202507/20 BOJ G4 2056 \354\236\221\354\227\205.md" => "03do-new30/202507/20 BOJ G4 \354\236\221\354\227\205.md" (99%) diff --git "a/03do-new30/202507/20 BOJ G4 2056 \354\236\221\354\227\205.md" "b/03do-new30/202507/20 BOJ G4 \354\236\221\354\227\205.md" similarity index 99% rename from "03do-new30/202507/20 BOJ G4 2056 \354\236\221\354\227\205.md" rename to "03do-new30/202507/20 BOJ G4 \354\236\221\354\227\205.md" index e4c5003e..429e3cef 100644 --- "a/03do-new30/202507/20 BOJ G4 2056 \354\236\221\354\227\205.md" +++ "b/03do-new30/202507/20 BOJ G4 \354\236\221\354\227\205.md" @@ -60,4 +60,5 @@ public class Main { return ret; } } + ```