• Home
  • About
    • JOOS photo

      JOOS

      Joos's blog

    • Learn More
    • Email
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

[백준] 11052번 : 붕어빵 판매하기 with python3

23 Aug 2018

Reading time ~1 minute

https://www.acmicpc.net/problem/11726

n = int(input())
prices = list(map(int, input().split()))
prices.insert(0,0)
#인덱스 헷갈리고 싶지 않아서 그냥 이렇게 맞춰줍니다.
d = [0]*(n+1)

d[1] = prices[1]
for i in range(2,n+1):
    for j in range(1,i+1):
        d[i] = max(d[i], d[i-j]+prices[j])

print(d[n])

d에는 몇 개 팔 때 max 가격



algorithm백준 Share Tweet +1