Skip to content

Commit 898b369

Browse files
committed
πŸ‘‘ G5-11000
1 parent 84efec7 commit 898b369

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

β€ŽπŸ‘‘ G5/11000.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import sys
2+
from heapq import *
3+
input = sys.stdin.readline
4+
5+
n = int(input())
6+
lecture = [list(map(int, input().split())) for _ in range(n)]
7+
lecture.sort(key=lambda x: (x[0], x[1]))
8+
lectureroom = [lecture[0][1]]
9+
heapify(lectureroom)
10+
11+
for i in range(1, n):
12+
if lecture[i][0] >= lectureroom[0]:
13+
heappop(lectureroom)
14+
heappush(lectureroom, lecture[i][1])
15+
16+
print(len(lectureroom))

0 commit comments

Comments
Β (0)