From 2a55ac712047ab51c296ffd065be8b74a5756e2a Mon Sep 17 00:00:00 2001 From: oncsr Date: Fri, 14 Mar 2025 08:52:46 +0900 Subject: [PATCH] =?UTF-8?q?[20250313]=20BOJ=20/=20P5=20/=20=EC=9A=B4?= =?UTF-8?q?=EC=A0=84=20=EB=A9=B4=ED=97=88=20=EC=8B=9C=ED=97=98=20/=20?= =?UTF-8?q?=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\355\227\210 \354\213\234\355\227\230.md" | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 "khj20006/202503/13 BOJ P5 \354\232\264\354\240\204 \353\251\264\355\227\210 \354\213\234\355\227\230.md" diff --git "a/khj20006/202503/13 BOJ P5 \354\232\264\354\240\204 \353\251\264\355\227\210 \354\213\234\355\227\230.md" "b/khj20006/202503/13 BOJ P5 \354\232\264\354\240\204 \353\251\264\355\227\210 \354\213\234\355\227\230.md" new file mode 100644 index 00000000..eaca64bc --- /dev/null +++ "b/khj20006/202503/13 BOJ P5 \354\232\264\354\240\204 \353\251\264\355\227\210 \354\213\234\355\227\230.md" @@ -0,0 +1,101 @@ +```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 = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() throws Exception { + if(!st.hasMoreTokens()) nextLine(); + return Integer.parseInt(st.nextToken()); + } + static long nextLong() throws Exception { + if(!st.hasMoreTokens()) nextLine(); + return Long.parseLong(st.nextToken()); + } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static final int INF = 1000111777; + + static int N, M, L, G; + static int[][] right, down; + static int[][][][] D; + + + public static void main(String[] args) throws Exception { + + for(int T=nextInt();T-->0;) { + + ready(); + solve(); + } + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + L = nextInt(); + G = nextInt(); + right = new int[N][M]; + down = new int[N][M]; + D = new int[N][M][Math.min(N-1, M-1)*2+2][2]; + + for(int i=0;i0) { + D[i][j][k][0] = right[i][j-1]; + int res = D[i][j-1][k][0]; + if(k > 0) res = Math.min(res, D[i][j-1][k-1][1]); + D[i][j][k][0] += res; + } + if(i>0) { + D[i][j][k][1] = down[i-1][j]; + int res = D[i-1][j][k][1]; + if(k > 0) res = Math.min(res, D[i-1][j][k-1][0]); + D[i][j][k][1] += res; + } + } + + } + +} + +```