문제 링크
https://www.acmicpc.net/problem/11000
11000번: 강의실 배정
첫 번째 줄에 N이 주어진다. (1 ≤ N ≤ 200,000) 이후 N개의 줄에 Si, Ti가 주어진다. (0 ≤ Si < Ti ≤ 109)
www.acmicpc.net
문제 풀이
import heapq
n = int(input())
times = []
for _ in range(n):
times.append(list(map(int, input().split())))
times.sort()
room = []
heapq.heappush(room, times[0][1])
for i in range(1, n):
if times[i][0] < room[0]:
heapq.heappush(room, times[i][1])
else:
heapq.heappop(room)
heapq.heappush(room, times[i][1])
print(len(room))
'Algorithm > BOJ' 카테고리의 다른 글
[백준] 7576 토마토 (파이썬 python) (0) | 2024.03.02 |
---|---|
[백준] 16120 PPAP (파이썬 python) (0) | 2024.03.01 |
[백준] 2839 설탕 배달 (파이썬 python) (1) | 2024.02.27 |
[백준] 5052 전화번호 목록 (파이썬 python) (0) | 2024.02.21 |
[백준] 5430 AC (파이썬 python) (1) | 2024.02.21 |