提交时间:2023-12-04 13:24:08
运行 ID: 113895
# include <bits/stdc++.h> using namespace std ; int cst [2000] , dp [2000] ; int main ( ) { int n ; cin >> n ; for ( int i = 1 ; i <= n ; i ++ ) { cin >> cst [i] ; } for( int i = 3 ; i <= n + 1 ; i ++ ) { dp [i] = min ( cst [i - 1] + dp [i - 1] , cst[i - 2] + dp [i - 2] ) ; } cout << dp [n] << endl ; return 0 ; }