728x90
https://www.acmicpc.net/problem/1106
1106번: 호텔
첫째 줄에 C와 형택이가 홍보할 수 있는 도시의 개수 N이 주어진다. C는 1,000보다 작거나 같은 자연수이고, N은 20보다 작거나 같은 자연수이다. 둘째 줄부터 N개의 줄에는 각 도시에서 홍보할 때
www.acmicpc.net
c, n = map(int, input().split())
data = []
ad = [list(map(int, input().split())) for _ in range(n)]
dp = [0] + [100000] * (c + 100)
for cost, customer in ad:
for cur_customer in range(customer, c + 101):
dp[cur_customer] = min(dp[cur_customer], dp[cur_customer - customer] + cost)
print(min(dp[c:c + 101]))
dp 어렵군..
반응형
'전.py' 카테고리의 다른 글
[python] 백준 4949 균형잡힌 세상 (0) | 2022.02.07 |
---|---|
[python] 백준 15829 Hashing (0) | 2022.02.07 |
[python] 백준 7568 덩치 (0) | 2022.02.04 |
[python] 백준 10773 제로 (0) | 2022.01.28 |
[python] 백준 11651 좌표 정렬하기 2 (0) | 2022.01.28 |