From f0bfbf6379724c1819f11ab2e0b278c82e89425b Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Sat, 9 Aug 2025 02:53:13 +0900 Subject: [PATCH] =?UTF-8?q?[20250809]=20BOJ=20/=20G5=20/=20=EC=A1=B0=20?= =?UTF-8?q?=EC=A7=9C=EA=B8=B0=20/=20=EA=B9=80=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... \354\241\260 \354\247\234\352\270\260.md" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "suyeun84/202508/09 BOJ G5 \354\241\260 \354\247\234\352\270\260.md" diff --git "a/suyeun84/202508/09 BOJ G5 \354\241\260 \354\247\234\352\270\260.md" "b/suyeun84/202508/09 BOJ G5 \354\241\260 \354\247\234\352\270\260.md" new file mode 100644 index 00000000..888bcdc4 --- /dev/null +++ "b/suyeun84/202508/09 BOJ G5 \354\241\260 \354\247\234\352\270\260.md" @@ -0,0 +1,29 @@ +```java +import java.io.*; +import java.util.*; + +public class boj2229 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringTokenizer st; + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + + public static void main(String[] args) throws Exception { + nextLine(); + int N = nextInt(); + nextLine(); + int[] score = new int[N+1]; + int[] dp = new int[N+1]; + dp[0] = 0; + int max = 0; + for (int i = 1; i <= N; i++) { + score[i] = nextInt(); + for (int j = i-1; j >= 1; j--) { + max = Math.max(max, Math.abs(score[i] - score[j]) + dp[j-1]); + } + dp[i] = max; + } + System.out.println(dp[N]); + } +} +```