diff --git "a/Ukj0ng/202511/14 BOJ G5 \354\265\234\354\206\214 \355\232\214\354\235\230\354\213\244 \352\260\234\354\210\230.md" "b/Ukj0ng/202511/14 BOJ G5 \354\265\234\354\206\214 \355\232\214\354\235\230\354\213\244 \352\260\234\354\210\230.md" new file mode 100644 index 00000000..b559a9f3 --- /dev/null +++ "b/Ukj0ng/202511/14 BOJ G5 \354\265\234\354\206\214 \355\232\214\354\235\230\354\213\244 \352\260\234\354\210\230.md" @@ -0,0 +1,51 @@ +``` +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 List events; + private static int N; + public static void main(String[] args) throws IOException { + init(); + + int answer = sweeping(); + + bw.write(answer + "\n"); + bw.flush(); + bw.close(); + br.close(); + } + + private static void init() throws IOException { + N = Integer.parseInt(br.readLine()); + events = new ArrayList<>(); + + for (int i = 0; i < N; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + events.add(new int[]{Integer.parseInt(st.nextToken()), 0}); + events.add(new int[]{Integer.parseInt(st.nextToken()), 1}); + } + + events.sort((o1, o2) -> { + if (o1[0] == o2[0]) return Integer.compare(o2[1], o1[1]); + return Integer.compare(o1[0], o2[0]); + }); + } + + private static int sweeping() { + int result = 0; + int count = 0; + + for (int[] event : events) { + if (event[1] == 0) count++; + else count--; + + result = Math.max(result, count); + } + + return result; + } +} +```