From 2f6d910c284c127d4bc5ec93644d4b8482643cd3 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Wed, 24 Sep 2025 23:31:46 +0900 Subject: [PATCH] =?UTF-8?q?[20250924]=20BOJ=20/=20G4=20/=20=ED=95=A8?= =?UTF-8?q?=EA=BB=98=20=EB=B8=94=EB=A1=9D=20=EC=8C=93=EA=B8=B0=20/=20?= =?UTF-8?q?=EC=9D=B4=EA=B0=95=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\241\235 \354\214\223\352\270\260.md" | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 "lkhyun/202509/24 BOJ G4 \355\225\250\352\273\230 \353\270\224\353\241\235 \354\214\223\352\270\260.md" diff --git "a/lkhyun/202509/24 BOJ G4 \355\225\250\352\273\230 \353\270\224\353\241\235 \354\214\223\352\270\260.md" "b/lkhyun/202509/24 BOJ G4 \355\225\250\352\273\230 \353\270\224\353\241\235 \354\214\223\352\270\260.md" new file mode 100644 index 00000000..3fad2dbe --- /dev/null +++ "b/lkhyun/202509/24 BOJ G4 \355\225\250\352\273\230 \353\270\224\353\241\235 \354\214\223\352\270\260.md" @@ -0,0 +1,50 @@ +```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 StringBuilder sb = new StringBuilder(); + static int N,M,H; + static List[] blocks; + + public static void main(String[] args) throws Exception { + st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + H = Integer.parseInt(st.nextToken()); + + blocks = new List[N+1]; + for (int i = 1; i <= N; i++) { + blocks[i] = new ArrayList<>(M+1); + } + + for (int i = 1; i <= N; i++) { + st = new StringTokenizer(br.readLine()); + while(st.hasMoreTokens()){ + blocks[i].add(Integer.parseInt(st.nextToken())); + } + blocks[i].add(0); //블록 안 쌓는 경우 고려 + } + + int[][] dp = new int[N+1][H+1];//dp[i][j] = i번째 학생까지 고려했을때, j 높이를 쌓는 경우의 수 + dp[0][0] = 1; + + for (int i = 1; i <= N; i++) { + for (int j = 0; j <= H; j++) { + for (int cur : blocks[i]) { + if(cur <= j){ + dp[i][j] += dp[i-1][j-cur]; + dp[i][j] %= 10007; + } + } + } + } + bw.write(dp[N][H] + ""); + bw.close(); + } + +} +```