From d1dbf74a1045c5335d7986bd851694b42f3da187 Mon Sep 17 00:00:00 2001 From: oncsr Date: Tue, 25 Feb 2025 23:44:15 +0900 Subject: [PATCH] =?UTF-8?q?[20250225]=20BOJ=20/=20P5=20/=20=EB=B6=80?= =?UTF-8?q?=EB=B6=84=EB=B0=B0=EC=97=B4=20=EA=B3=A0=EB=A5=B4=EA=B8=B0=20/?= =?UTF-8?q?=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 --- ...4 \352\263\240\353\245\264\352\270\260.md" | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 "khj20006/202502/25 BOJ P5 \353\266\200\353\266\204\353\260\260\354\227\264 \352\263\240\353\245\264\352\270\260.md" diff --git "a/khj20006/202502/25 BOJ P5 \353\266\200\353\266\204\353\260\260\354\227\264 \352\263\240\353\245\264\352\270\260.md" "b/khj20006/202502/25 BOJ P5 \353\266\200\353\266\204\353\260\260\354\227\264 \352\263\240\353\245\264\352\270\260.md" new file mode 100644 index 00000000..83836898 --- /dev/null +++ "b/khj20006/202502/25 BOJ P5 \353\266\200\353\266\204\353\260\260\354\227\264 \352\263\240\353\245\264\352\270\260.md" @@ -0,0 +1,89 @@ +```java + +import java.util.*; +import java.io.*; + + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + static long nextLong() {return Long.parseLong(st.nextToken());} + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N; + static int[] r; + static long[] A, C; + static int[][] L; + static boolean[] V; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = Integer.parseInt(br.readLine()); + + r = new int[N]; + C = new long[N]; + A = new long[N]; + L = new int[N][2]; + V = new boolean[N]; + nextLine(); + + + for(int i=0;i b[0]-a[0]); + + long ans = 0; + for(int[] now : L){ + int v = now[0], i = now[1]; + if(i>0 && V[i-1]){ + int x = f(i), y = f(i-1); + C[x] += C[y]; + r[y] = x; + } + if(i