From 95bfd26ab46d645a20dd05385fdf13b0b1701346 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Wed, 16 Jul 2025 15:13:56 +0900 Subject: [PATCH] =?UTF-8?q?[20250716]=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=EA=B9=80?= =?UTF-8?q?=EC=88=98=EC=97=B0?= 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" | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 "suyeun84/202507/16 BOJ G5 \352\260\225\354\235\230\354\213\244 \353\260\260\354\240\225.md" diff --git "a/suyeun84/202507/16 BOJ G5 \352\260\225\354\235\230\354\213\244 \353\260\260\354\240\225.md" "b/suyeun84/202507/16 BOJ G5 \352\260\225\354\235\230\354\213\244 \353\260\260\354\240\225.md" new file mode 100644 index 00000000..0b1d2077 --- /dev/null +++ "b/suyeun84/202507/16 BOJ G5 \352\260\225\354\235\230\354\213\244 \353\260\260\354\240\225.md" @@ -0,0 +1,43 @@ +```java +import java.util.*; +import java.io.*; + +public class boj11000 { + 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 answer = 0; + PriorityQueue rooms = new PriorityQueue<>(); + Time[] lec = new Time[N]; + for (int i = 0; i < N; i++) { + nextLine(); + int S = nextInt(); + int T = nextInt(); + lec[i] = new Time(S, T); + } + Arrays.sort(lec, (o1, o2) -> { + if (o1.s == o2.s) return o1.e - o2.e; + else return o1.s - o2.s; + }); + rooms.add(lec[0].e); + for (int i = 1; i < N; i++) { + if (rooms.peek() <= lec[i].s) rooms.poll(); + rooms.add(lec[i].e); + answer = Math.max(answer, rooms.size()); + } + System.out.println(answer); + } + static class Time { + int s, e; + public Time(int s, int e) { + this.s = s; + this.e = e; + } + } +} +```