Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[23-09-01] BOJ 1106 #199

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

[23-09-01] BOJ 1106 #199

wants to merge 2 commits into from

Conversation

cyjadela
Copy link
Contributor

@cyjadela cyjadela commented Sep 1, 2023

문제

#198

해결 과정

import sys
input = sys.stdin.readline

c, n = map(int, input().split())
cost_list = []

for i in range(n):
    cost, people = map(int, input().split())
    cost_list.append([cost, people])

dp = [1e7 for _ in range(c+100)] #최댓값이 100
dp[0] = 0

for cost, people in cost_list:
  for i in range(people, c+100):
    dp[i] = min(dp[i-people]+cost,dp[i])

print(min(dp[c:]))

메모리, 시간

백준 문제일 경우 아래에 입력해주세요

  • 31256KB
  • 52ms

알게된 것

문제를 보고 dp로 어떻게 풀어야겠다는 이제 감이 오는데 실제로 코드로 짜는게 아직 익숙하지 않은 것 같다 ..
책보고 다시 똑바로 공부해야지 !!

@cyjadela cyjadela added the 윤진 label Sep 1, 2023
@cyjadela cyjadela self-assigned this Sep 1, 2023
Copy link
Member

@GIVEN53 GIVEN53 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dp 길이를 길게 하는 것도 괜찮네요!

Copy link
Contributor

@13wjdgk 13wjdgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 dp가 어려워서 여러번 풀면서 연습했었어요 ~ 홧팅 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants