zoukankan      html  css  js  c++  java
  • 716-River Crossing

    深奥dp,状态转来转去,反正就是能解题

    #include <cstdio>
    #include <iostream>
    #include <cstring>
    #include <map>
    #include<vector>
    using namespace std;
    int dp[30004];
    int main()
    {
        int n,m,i,j,a;
        int t;
        scanf("%d",&t);
        while(t--)
        {
            memset(dp,0,sizeof(dp));
    
            scanf("%d%d",&n,&m);
            dp[0]=m;
            for(i=1; i<=n; i++)
            {
                scanf("%d",&a);
                dp[i]=dp[i-1]+a;
            }
            for(i=1; i<=n; i++)
            {
                for(j=1; j<=i; j++)
                {
                    dp[i]=min(dp[i],dp[i-j]+dp[j]+m);
                }
            }
    
    
            printf("%d
    ",dp[n]);
    
    
        }
    
    }
  • 相关阅读:
    派生选择器
    HTML 标签
    $.get()
    CC150
    CC150
    CC150
    CC150
    HashMap和HashTable的区别
    CC150
    quickSort
  • 原文地址:https://www.cnblogs.com/nr1999/p/9066964.html
Copyright © 2011-2022 走看看