목차

강의실 배정

ps
링크acmicpc.net/…
출처BOJ
문제 번호11000
문제명강의실 배정
레벨골드 5
분류

스위핑

시간복잡도O(nlogn)
인풋사이즈n<=200000
사용한 언어Python
제출기록75868KB / 416ms
최고기록328ms
해결날짜2022/01/13

풀이

코드

"""Solution code for "BOJ 11000. 강의실 배정".

- Problem link: https://www.acmicpc.net/problem/11000
- Solution link: http://www.teferi.net/ps/problems/boj/11000

Tags: [Sweeping]
"""

import sys

INF = float('inf')

END = 0
START = 1


def main():
    N = int(sys.stdin.readline())
    times = []
    for _ in range(N):
        S, T = [int(x) for x in sys.stdin.readline().split()]
        times.append((S, START))
        times.append((T, END))

    lecture_count = 0
    answer = max(
        (lecture_count := lecture_count + (1 if event == START else -1))
        for _, event in sorted(times))

    print(answer)


if __name__ == '__main__':
    main()