We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 8f09127 + 4e98780 commit 63ff5d4Copy full SHA for 63ff5d4
1 file changed
suyeun84/202510/14 BOJ G4 수도배관공사.md
@@ -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
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