From 8109186e52b7ea83f7cf55f9903289aeacee520b Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Tue, 29 Jul 2025 23:07:08 +0900 Subject: [PATCH] =?UTF-8?q?[20250729]=20BOJ=20/=20G5=20/=20=EA=B0=95?= =?UTF-8?q?=EC=9D=98=EC=8B=A4=20=EB=B0=B0=EC=A0=95=20/=20=EC=9D=B4?= =?UTF-8?q?=EA=B0=95=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\213\244 \353\260\260\354\240\225.md" | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 "lkhyun/202507/29 BOJ G5 \352\260\225\354\235\230\354\213\244 \353\260\260\354\240\225.md" diff --git "a/lkhyun/202507/29 BOJ G5 \352\260\225\354\235\230\354\213\244 \353\260\260\354\240\225.md" "b/lkhyun/202507/29 BOJ G5 \352\260\225\354\235\230\354\213\244 \353\260\260\354\240\225.md" new file mode 100644 index 00000000..82a985a9 --- /dev/null +++ "b/lkhyun/202507/29 BOJ G5 \352\260\225\354\235\230\354\213\244 \353\260\260\354\240\225.md" @@ -0,0 +1,35 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + static int N; + + public static void main(String[] args) throws Exception { + N = Integer.parseInt(br.readLine()); + List arr = new LinkedList<>(); + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + arr.add(new int[]{Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken())}); + } + Collections.sort(arr,(a,b) -> a[0] - b[0]); + + PriorityQueue pq = new PriorityQueue<>(); + + int ans = 1; + for (int[] cur : arr) { + while(!pq.isEmpty() && pq.peek() <= cur[0]){ + pq.poll(); + } + pq.offer(cur[1]); + ans = Math.max(ans,pq.size()); + } + bw.write(ans+""); + bw.close(); + } +} +```