File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ ```java
2+ import java.util.*;
3+ import java.io.*;
4+
5+ public class boj29704 {
6+ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+ static StringTokenizer st;
8+ static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());}
9+ static int nextInt() {return Integer.parseInt(st.nextToken());}
10+
11+ static int n;
12+ static int t;
13+ static int[] dp;
14+
15+ public static void main(String[] args) throws Exception {
16+ nextLine();
17+ n = nextInt();
18+ t = nextInt();
19+ dp = new int[t+1];
20+
21+ int all = 0;
22+ while (n-- > 0) {
23+ nextLine();
24+ int d = nextInt();
25+ int m = nextInt();
26+ all += m;
27+
28+ for (int i = t; i >= 0; i--) {
29+ if (i < d) break;
30+ dp[i] = Math.max(dp[i], dp[i-d] +m);
31+ }
32+ }
33+
34+ System.out.println(all - dp[t]);
35+ }
36+ }
37+ ```
You can’t perform that action at this time.
0 commit comments