From 4e98780f1ad1b5a24bb806c6b37f82629e6d477b Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Tue, 14 Oct 2025 23:23:56 +0900 Subject: [PATCH] =?UTF-8?q?[20251014]=20BOJ=20/=20G4=20/=20=EC=88=98?= =?UTF-8?q?=EB=8F=84=EB=B0=B0=EA=B4=80=EA=B3=B5=EC=82=AC=20/=20=EA=B9=80?= =?UTF-8?q?=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...60\352\264\200\352\263\265\354\202\254.md" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "suyeun84/202510/14 BOJ G4 \354\210\230\353\217\204\353\260\260\352\264\200\352\263\265\354\202\254.md" diff --git "a/suyeun84/202510/14 BOJ G4 \354\210\230\353\217\204\353\260\260\352\264\200\352\263\265\354\202\254.md" "b/suyeun84/202510/14 BOJ G4 \354\210\230\353\217\204\353\260\260\352\264\200\352\263\265\354\202\254.md" new file mode 100644 index 00000000..2a87efc0 --- /dev/null +++ "b/suyeun84/202510/14 BOJ G4 \354\210\230\353\217\204\353\260\260\352\264\200\352\263\265\354\202\254.md" @@ -0,0 +1,28 @@ +```java +import java.io.*; +import java.util.*; + +public class boj2073 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringTokenizer st; + static void nextLine() throws Exception { st = new StringTokenizer(br.readLine()); } + static int nextInt() { return Integer.parseInt(st.nextToken()); } + + public static void main(String[] args) throws Exception { + nextLine(); + int D = nextInt(); + int P = nextInt(); + int[] dp = new int[D+1]; + dp[0] = Integer.MAX_VALUE; + for (int i = 0; i < P; i++) { + nextLine(); + int L = nextInt(); //길이 + int C = nextInt(); //용량 + for (int j = D; j >= L; j--) { + dp[j] = Math.max(dp[j], Math.min(C, dp[j-L])); + } + } + System.out.println(dp[D]); + } +} +```