Skip to content

Commit 4e98780

Browse files
authored
[20251014] BOJ / G4 / 수도배관공사 / 김수연
1 parent c4da44f commit 4e98780

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
```

0 commit comments

Comments
 (0)