From af696a3104eeae7a1f76a024bd66516ebb18955c Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Fri, 18 Apr 2025 11:03:31 +0900 Subject: [PATCH] =?UTF-8?q?[20250418]=20BOJ=20/=20G5=20/=20=ED=9A=8C?= =?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" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "lkhyun/202504/18 BOJ G5 \355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.md" diff --git "a/lkhyun/202504/18 BOJ G5 \355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.md" "b/lkhyun/202504/18 BOJ G5 \355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.md" new file mode 100644 index 00000000..30dbf4a3 --- /dev/null +++ "b/lkhyun/202504/18 BOJ G5 \355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.md" @@ -0,0 +1,40 @@ +```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()); + PriorityQueue pq = new PriorityQueue<>((a, b) -> { + if (a[1] == b[1]) { + return a[0] - b[0]; + } else { + return a[1] - b[1]; + } + }); + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + pq.add(new int[] {Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken())}); + } + int cnt = 0; + int curTime = 0; + while (!pq.isEmpty()) { + int[] cur = pq.poll(); + if (cur[0] >= curTime) { + cnt++; + curTime = cur[1]; + } + } + bw.write(cnt + ""); + bw.close(); + } +} + + + +```