提交时间:2023-11-25 17:01:11
运行 ID: 112340
#include<bits/stdc++.h> #define int long long using namespace std; int a[1145],dp[1145]; signed main(){ int n; cin>>n; for (int i = 1;i <= n;i++){ cin>>a[i]; } memset(dp,0x7f7f7f7f,sizeof(dp)); dp[0] = dp[1] = 0; for (int i = 0;i <= n;i++){ dp[i + 1] = min(dp[i + 1],dp[i] + a[i]); dp[i + 2] = min(dp[i + 2],dp[i] + a[i]); } cout<<dp[n + 1]; return 0; }