tyvj1015 - 公路乘车 ——完全背包

July 7, 2013
tyvj DP

题目链接:https://www.tyvj.cn/Problem_Show.aspx?id=1015 完全背包


#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int c[11],f[101];
int main(void) {
    freopen("in1.txt","r",stdin);
    int n,i,j;for(i=1;i<=10;scanf("%d",c+i++))
        ;scanf("%d",&n);
    for(i=1;i<=n;f[i++]=100000)
        ;
    for(i=1;i<=10;++i)for(j=i;j<=n;++j)f[j]=min(f[j],f[j-i]+c[i]);
    printf("%d\n",f[n]);
    return 0;
}

0x3f3f3f3f可以memset-_-#

comments powered by Disqus