Skip to content

Commit

Permalink
[BOJ] 1106 : 호텔
Browse files Browse the repository at this point in the history
  • Loading branch information
GIVEN53 committed Sep 1, 2023
1 parent 2ff2aa3 commit ac50f21
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gibeom/23-09-01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from sys import stdin

c, n = map(int, stdin.readline().split())
city = [list(map(int, stdin.readline().split())) for _ in range(n)]
dp = [1e9] * (c + 1)
dp[0] = 0

for i in range(1, c + 1):
for cost, customer in city:
if i <= customer:
dp[i] = min(dp[i], cost)
else:
dp[i] = min(dp[i], dp[i - customer] + cost)

print(dp[-1])

##########################
# memory: 31256KB #
# time: 52ms #
##########################

0 comments on commit ac50f21

Please sign in to comment.