File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.* ;
3+ import java.util.* ;
4+
5+ public class boj2073 {
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+ public static void main(String [] args) throws Exception {
12+ nextLine();
13+ int D = nextInt();
14+ int P = nextInt();
15+ int [] dp = new int [D + 1 ];
16+ dp[0 ] = Integer . MAX_VALUE ;
17+ for (int i = 0 ; i < P ; i++ ) {
18+ nextLine();
19+ int L = nextInt(); // 길이
20+ int C = nextInt(); // 용량
21+ for (int j = D ; j >= L ; j-- ) {
22+ dp[j] = Math . max(dp[j], Math . min(C , dp[j- L ]));
23+ }
24+ }
25+ System . out. println(dp[D ]);
26+ }
27+ }
28+ ```
You can’t perform that action at this time.
0 commit comments