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"); + + } + +} +```