Python/백준(BOJ) 알고리즘
[백준] - 1931 파이썬 python
Present_Kim
2021. 7. 11. 17:22
· 풀이
끝나는 시간, 시작 하는 시간 기준으로 정렬 후, 시간 하는 시간이 전의 끝나는 시간 이후면 count.
arr = []
n = int(input())
for i in range(n):
arr.append(list(map(int,input().split())))
arr.sort(key=lambda x:(x[1],x[0]))
count = 0
pre_end = 0
for start, end in arr:
if start >= pre_end:
pre_end = end
count += 1
print(count)