From 4d379dfeff795443dc3286d2ffe19d4a9d6e0a98 Mon Sep 17 00:00:00 2001 From: Ukj0ng <90972240+Ukj0ng@users.noreply.github.com> Date: Thu, 11 Sep 2025 21:36:23 +0900 Subject: [PATCH] =?UTF-8?q?[20250911]=20BOJ=20/=20G5=20/=20=EB=B2=BC?= =?UTF-8?q?=EB=9D=BD=EC=B9=98=EA=B8=B0=20/=20=ED=95=9C=EC=A2=85=EC=9A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...74\353\235\275\354\271\230\352\270\260.md" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "Ukj0ng/202509/11 BOJ G5 \353\262\274\353\235\275\354\271\230\352\270\260.md" diff --git "a/Ukj0ng/202509/11 BOJ G5 \353\262\274\353\235\275\354\271\230\352\270\260.md" "b/Ukj0ng/202509/11 BOJ G5 \353\262\274\353\235\275\354\271\230\352\270\260.md" new file mode 100644 index 00000000..7b449a14 --- /dev/null +++ "b/Ukj0ng/202509/11 BOJ G5 \353\262\274\353\235\275\354\271\230\352\270\260.md" @@ -0,0 +1,40 @@ +``` +import java.io.*; +import java.util.*; + +public class Main { + private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + private static int[] dp; + private static int n, t; + + public static void main(String[] args) throws IOException { + init(); + solve(); + + bw.write(dp[t] + "\n"); + bw.flush(); + bw.close(); + br.close(); + } + + private static void init() throws IOException { + StringTokenizer st = new StringTokenizer(br.readLine()); + n = Integer.parseInt(st.nextToken()); + t = Integer.parseInt(st.nextToken()); + dp = new int[t + 1]; + } + + private static void solve() throws IOException { + for (int i = 0; i < n; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + int k = Integer.parseInt(st.nextToken()); + int s = Integer.parseInt(st.nextToken()); + + for (int j = t; j >= k; j--) { + dp[j] = Math.max(dp[j], dp[j - k] + s); + } + } + } +} +```