提交时间:2023-11-25 09:33:13

运行 ID: 111970

#include<bits/stdc++.h> using namespace std; int dp[1001]; int cost[1001]; signed main(){ int n; cin >> n; for(int i = 1;i <= n;i++){ cin >> cost[i]; } for(int i= 2;i <= n;i++){ dp[i] = min(dp[i-1] + cost[i],dp[i-2] + cost[i-1]); } cout << dp[n]; }