提交时间:2023-12-04 13:23:31
运行 ID: 113894
# 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 ; i ++ ) { dp [i] = min ( cst [i - 1] + dp [i - 1] , cst[i - 2] + dp [i - 2] ) ; } cout << dp [n] << endl ; return 0 ; }