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(); + } +} +```