Skip to content

Commit

Permalink
[solved] boj18427
Browse files Browse the repository at this point in the history
  • Loading branch information
leetaggg committed Oct 5, 2023
1 parent dca87f5 commit 403bd04
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions LeeTaeHo/boj/boj18427.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.io.*;
import java.util.*;

public class boj18427 {

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
st.nextToken();
int h = Integer.parseInt(st.nextToken());

int[] dp = new int[h + 1];

List<Integer>[] block = new ArrayList[n + 1];

for (int i = 1; i <= n; i++) {
block[i] = new ArrayList<>();
st = new StringTokenizer(br.readLine());
while (st.hasMoreTokens()){
block[i].add(Integer.parseInt(st.nextToken()));
}
}

dp[0] = 1;

for (int i = 1; i <= n; i++) {
for (int j = h; j >= 0; j--) {
for (int k : block[i]) {
if(j - k >= 0){
dp[j] += dp[j - k];
dp[j] %= 10007;
}
}
}
}

System.out.println(dp[h]);
}
}

0 comments on commit 403bd04

Please sign in to comment.