From 3a476f408c7f01ce45012a0e55a2f4c030265162 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Sun, 29 Jun 2025 20:19:45 +0900 Subject: [PATCH] =?UTF-8?q?[20250629]=20BOJ=20/=20G4=20/=20RGB=EA=B1=B0?= =?UTF-8?q?=EB=A6=AC=202=20/=20=EC=9D=B4=EA=B0=95=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...9 BOJ G4 RGB\352\261\260\353\246\254 2.md" | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "lkhyun/202506/29 BOJ G4 RGB\352\261\260\353\246\254 2.md" diff --git "a/lkhyun/202506/29 BOJ G4 RGB\352\261\260\353\246\254 2.md" "b/lkhyun/202506/29 BOJ G4 RGB\352\261\260\353\246\254 2.md" new file mode 100644 index 00000000..31615199 --- /dev/null +++ "b/lkhyun/202506/29 BOJ G4 RGB\352\261\260\353\246\254 2.md" @@ -0,0 +1,45 @@ +```java +import java.util.*; +import java.io.*; +public class Main { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + static int N; + static int[][] cost; + static int[][] dp; + + public static void main(String[] args) throws Exception{ + N = Integer.parseInt(br.readLine()); + cost = new int[N+1][3]; + + for(int i=1; i<=N;i++){ + st = new StringTokenizer(br.readLine()); + cost[i][0] = Integer.parseInt(st.nextToken()); + cost[i][1] = Integer.parseInt(st.nextToken()); + cost[i][2] = Integer.parseInt(st.nextToken()); + } + + int min = Integer.MAX_VALUE; + for(int firstColor=0; firstColor<3; firstColor++){ + dp = new int[N+1][3]; + dp[1][firstColor] = cost[1][firstColor]; + dp[1][(firstColor+1)%3] = 10000000; + dp[1][(firstColor+2)%3] = 10000000; + + for(int i=2;i