Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9270765

Browse files
committed
[BOJ] 2073 수도배관공사_241026
1 parent e1c1013 commit 9270765

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎BOJ/1000-5000번/YJ_2073.java‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import java.io.*;
2+
3+
public class YJ_2073 {
4+
public static void main(String[] args) throws IOException {
5+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
6+
String[] DP = br.readLine().split("\\s");
7+
int D = Integer.parseInt(DP[0]);
8+
int P = Integer.parseInt(DP[1]);
9+
10+
int[] length = new int[P];
11+
int[] capacity = new int[P];
12+
for(int i=0; i<P; i++){
13+
String[] data = br.readLine().split("\\s");
14+
length[i] = Integer.parseInt(data[0]);
15+
capacity[i] = Integer.parseInt(data[1]);
16+
}
17+
18+
int[] dp = new int[D+1]; //dp[특정거리] = 최대 용량
19+
dp[0] = Integer.MAX_VALUE; //초기 상태에서의 최소 용량을 설정하기 위해서 최대 정수를 설정
20+
21+
// 특정 거리에 만들 수 있는 수도관(여러 파이프들로 구성) 중 가장 큰 용량 구하기
22+
for(int i=0; i<P; i++){
23+
for(int distance=D; distance>=length[i]; distance--){
24+
//특정 거리에 만들 수 있는 수도관(여러 파이프들로 구성) 중 가장 큰 용량 구하기
25+
dp[distance] = Math.max(dp[distance], Math.min(capacity[i],dp[distance-length[i]]));
26+
}
27+
}
28+
29+
System.out.println(dp[D]);
30+
}
31+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /