题解 | #最小代价爬楼梯#
最小代价爬楼梯
http://www.nowcoder.com/practice/355885694012495281f415387db22fde
include
include
using namespace std;
int main(){
    vector<int> cost;
    int c;
    while(scanf("%d,", &c) > 0){
        cost.push_back(c);
    }
    int l = cost.size();
    int total_cost;
    vector<int> dp(l, 0);
    for(int i = 0; i < l; i ++){
        if(i == 0) dp[i] = cost[0];
        else if(i == 1) dp[i] = min(cost[0] + cost[1], cost[1]);
        else{
            dp[i] = min(dp[i - 1] + cost[i], dp[i - 2] + cost[i]);
        }
         // cout << dp[i]<<' ';
    }
    cout << min(dp[l - 1], dp[l - 2]);
}</int></int>
 投递哔哩哔哩等公司10个岗位
投递哔哩哔哩等公司10个岗位
