提交时间:2023-11-27 14:01:28

运行 ID: 112641

#include<bits/stdc++.h> using namespace std; #define int long long int cst[200000], dp[200000]; int n; signed main(){ ios::sync_with_stdio(false); cin >> n; for(int i = 0 ; i < n ; i++) cin >> cst[i]; for(int i = 2 ; i <= n ; i++){ dp[i] = min(dp[i - 1] + cst[i - 1], dp[i - 2] + cst[i - 2]); } cout << dp[n] << endl; return 0; }