From f302c81217eec06fe5e2b041dcf8c2ac493f9850 Mon Sep 17 00:00:00 2001 From: oncsr Date: Fri, 27 Jun 2025 23:04:46 +0900 Subject: [PATCH] =?UTF-8?q?[20250627]=20BOJ=20/=20P5=20/=20=EC=87=BC?= =?UTF-8?q?=ED=95=91=EB=AA=B0=20/=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5 \354\207\274\355\225\221\353\252\260.md" | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 "khj20006/202506/27 BOJ P5 \354\207\274\355\225\221\353\252\260.md" diff --git "a/khj20006/202506/27 BOJ P5 \354\207\274\355\225\221\353\252\260.md" "b/khj20006/202506/27 BOJ P5 \354\207\274\355\225\221\353\252\260.md" new file mode 100644 index 00000000..c1d31490 --- /dev/null +++ "b/khj20006/202506/27 BOJ P5 \354\207\274\355\225\221\353\252\260.md" @@ -0,0 +1,121 @@ +```java +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static int N, M, K; + static List[] V; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + public static void init() throws Exception { + + N = io.nextInt(); + M = io.nextInt(); + K = io.nextInt(); + V = new List[N+1]; + for(int i=1;i<=N;i++) V[i] = new ArrayList<>(); + for(int i=0;i Q = new PriorityQueue<>((a,b) -> a[0]-b[0]); + for(int i=0;i D[n]) continue; + for(int[] e:V[n]) { + int i = e[0], c = e[1]; + if(D[i] > d+c) { + D[i] = d+c; + Q.offer(new int[]{D[i],i}); + } + } + } + + int ans = 0; + for(int n=1;n<=N;n++) for(int[] e:V[n]) { + int i = e[0], c = e[1]; + if(D[n] + c == D[i]) continue; + ans = Math.max(Math.max(ans, D[n]*2), Math.max(D[i]*2, (D[n]+D[i]+c))); + } + + io.write((ans+1)/2 + "\n"); + + } + +} +```