Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

Deep CV

[백준] - 1931 파이썬 python 본문

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)

'Python > 백준(BOJ) 알고리즘' 카테고리의 다른 글

[백준] - 1946파이썬 python  (0) 2021.07.14
[백준] - 13305 파이썬 python  (0) 2021.07.11
[백준] - 1541파이썬 python  (0) 2021.07.11
[백준] - 11399 파이썬 python  (0) 2021.07.11
[백준] - 11047 파이썬 python  (0) 2021.07.11