0
0

paizaラーニング問題集「最安値を達成するには1」を解いてみた

Last updated at Posted at 2024-09-19

▼感想:

本問を基礎として、次以降の問題を解くことができればと思います。

▼コード:

########## 処理0(準備) インプット,リスト定義など ###########

n,a,b = map(int,input().split())

dp = [0]*(1000+1)

########## 処理1 漸化式の定義、計算、出力 ##########

dp[0] = 0
dp[1] = a

for i in range(2,n+1):
    dp[i] = min(dp[i-1]+a,dp[i-2]+b)

print(dp[n])
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0