반응형
Notice
Recent Posts
Recent Comments
Link
동캄의 코딩도장
백준 1931 [회의실 배정] 파이썬 본문
반응형
https://www.acmicpc.net/problem/1931
1931번: 회의실 배정
(1,4), (5,7), (8,11), (12,14) 를 이용할 수 있다.
www.acmicpc.net
#백준 1931
import sys
n=int(sys.stdin.readline())
lst=[]
for i in range(n):
s=list(map(int,sys.stdin.readline().split()))
lst.append(s)
lst.sort(key=lambda x:(x[1],x[0]))
ans=0
t=-1
for i in range(n):
if lst[i][0]>=t:
ans+=1
t=lst[i][1]
print(ans)
(끝 시간을 기준으로 정렬)
그리디한 문제이다.
반응형
'코테 > BOJ' 카테고리의 다른 글
백준 15903 [카드 합체 놀이] 파이썬 (0) | 2022.09.04 |
---|---|
백준 1541 [잃어버린 괄호] 파이썬 (0) | 2022.09.04 |
백준 14247 [나무 자르기] 파이썬 (0) | 2022.09.04 |
백준 2232 [지뢰] 파이썬 (0) | 2022.09.04 |
백준 17451 [평행 우주] 파이썬 (0) | 2022.09.04 |