From 87ec0fc4336483820dad9b171ea4df62710be259 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Sat, 14 Jun 2025 23:32:49 +0900 Subject: [PATCH] =?UTF-8?q?[20250614]=20BOJ=20/=20G3=20/=20=EC=88=9C?= =?UTF-8?q?=ED=9A=8C=EA=B0=95=EC=97=B0=20/=20=EA=B9=80=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\355\232\214\352\260\225\354\227\260.md" | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 "suyeun84/202506/14 BOJ G3 \354\210\234\355\232\214\352\260\225\354\227\260.md" diff --git "a/suyeun84/202506/14 BOJ G3 \354\210\234\355\232\214\352\260\225\354\227\260.md" "b/suyeun84/202506/14 BOJ G3 \354\210\234\355\232\214\352\260\225\354\227\260.md" new file mode 100644 index 00000000..521249f6 --- /dev/null +++ "b/suyeun84/202506/14 BOJ G3 \354\210\234\355\232\214\352\260\225\354\227\260.md" @@ -0,0 +1,39 @@ +```java +import java.io.*; +import java.util.*; + +public class boj2109 { + 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 N = nextInt(); + int[][] arr = new int[N][2]; + int[] store = new int[10001]; + int answer = 0; + for (int i = 0; i < N; i++) { + nextLine(); + arr[i][0] = nextInt(); + arr[i][1] = nextInt(); + } + Arrays.sort(arr, (o1, o2) -> { + return o2[0] - o1[0]; + }); + for (int i = 0; i < N; i++) { + int cost = arr[i][0]; + int day = arr[i][1]; + for (int j = day; j >= 1; j--) { + if (store[j] < cost) { + store[j] = cost; + break; + } + } + } + for (int i = 0; i < 10001; i++) answer += store[i]; + System.out.println(answer); + } +} +```