일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 동적 계획법
- 그리디
- python
- 이분탐색
- lambda
- Zip
- KAKAO BLIND RECRUITMENT
- heapq
- dfs
- 파이썬
- 카카오
- divmod
- Set
- programmers
- DateTime
- Re
- 다익스트라
- 프로그래머스
- Combinations
- 자바
- 정규식
- 정렬
- 백준
- backjoon
- 위클리 챌린지
- 수학
- BFS
- java
- 추석맞이 코딩챌린지
- 재귀함수
Archives
- Today
- Total
상상쓰
[백준] 회의실 배정 본문
https://www.acmicpc.net/problem/1931
1931번: 회의실 배정
(1,4), (5,7), (8,11), (12,14) 를 이용할 수 있다.
www.acmicpc.net
백준 문제는 브라우저에서 테스트가 힘들어서 프로그래머스를 풀었었는데 오랜만에 들어가서 풀어봤다.
그리디 알고리즘 문제로 어렵지 않다.
N = int(input())
times = []
for i in range(N):
times.append(list(map(int, input().split())))
answer = 1
times = sorted(times, key = lambda x : (x[1], x[0]))
end = times[0][1]
for i in range(1, N):
if end <= times[i][0]:
end = times[i][1]
answer = answer + 1
print(answer) # 4
'Coding Test' 카테고리의 다른 글
[프로그래머스] 기둥과 보 설치 (0) | 2021.06.04 |
---|---|
[백준] 거스름돈 (0) | 2021.06.04 |
[프로그래머스] 길 찾기 게임 (0) | 2021.06.04 |
[프로그래머스] 가장 큰 수 (0) | 2021.06.03 |
[프로그래머스] 자물쇠와 열쇠 (0) | 2021.06.02 |
Comments