From 4003203537a215f9125c537c61698eb3cfd5fd86 Mon Sep 17 00:00:00 2001 From: Ukj0ng <90972240+Ukj0ng@users.noreply.github.com> Date: Fri, 6 Feb 2026 10:36:36 +0900 Subject: [PATCH] =?UTF-8?q?[20260206]=20BOJ=20/=20G3=20/=20=EC=88=9C?= =?UTF-8?q?=ED=9A=8C=EA=B0=95=EC=97=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 --- ...34\355\232\214\352\260\225\354\227\260.md" | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 "Ukj0ng/202602/06 BOJ G3 \354\210\234\355\232\214\352\260\225\354\227\260.md" diff --git "a/Ukj0ng/202602/06 BOJ G3 \354\210\234\355\232\214\352\260\225\354\227\260.md" "b/Ukj0ng/202602/06 BOJ G3 \354\210\234\355\232\214\352\260\225\354\227\260.md" new file mode 100644 index 00000000..8e41d93f --- /dev/null +++ "b/Ukj0ng/202602/06 BOJ G3 \354\210\234\355\232\214\352\260\225\354\227\260.md" @@ -0,0 +1,62 @@ +``` +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 final int INF = 10000; + private static PriorityQueue pq; + private static long[] arr; + private static long answer; + private static int N; + + public static void main(String[] args) throws IOException { + init(); + + bw.write(answer + "\n"); + bw.flush(); + bw.close(); + br.close(); + } + + private static void init() throws IOException { + N = Integer.parseInt(br.readLine()); + pq = new PriorityQueue<>((o1, o2) -> Double.compare(o2.cost, o1.cost)); + arr = new long[INF+1]; + + for (int i = 1; i <= N; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + int p = Integer.parseInt(st.nextToken()); + int d = Integer.parseInt(st.nextToken()); + + pq.add(new College(d, p)); + } + + while (!pq.isEmpty()) { + College current = pq.poll(); + + for (int i = current.day; i > 0; i--) { + if (arr[i] < current.cost) { + arr[i] = current.cost; + break; + } + } + } + + for (int i = 1; i <= INF; i++) { + answer += arr[i]; + } + } + + static class College { + int day; + int cost; + + College (int day, int cost) { + this.day = day; + this.cost = cost; + } + } +} +```