diff --git "a/khj20006/202509/26 BOJ G4 \352\265\220\353\217\204\354\206\214.md" "b/khj20006/202509/26 BOJ G4 \352\265\220\353\217\204\354\206\214.md" new file mode 100644 index 00000000..e7e8451a --- /dev/null +++ "b/khj20006/202509/26 BOJ G4 \352\265\220\353\217\204\354\206\214.md" @@ -0,0 +1,90 @@ +```java +import java.io.*; +import java.util.*; + +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; + static long[] a; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + N = io.nextInt(); + a = new long[N]; + long s = 0; + for(int i=0;i s) { + long diff = a[cur] - s; + ans += diff; + a[cur] -= diff; + a[next] += diff; + } + } + io.write(ans + "\n"); + + io.close(); + + } + +} +```