标签:des style blog color java os io strong
1 50 5 10 1 2 3 2 1 1 2 3 2 1 50 0
-45 32
#include<iostream> #include<cstdio> #include<cmath> #include<queue> #include<algorithm> #include<cstring> using namespace std; int main() { int n,i,j,v; while(scanf("%d",&n)!=EOF){ if(n==0)break; int dp[1100]={0},c[1100]; for(i=0;i<n;i++) scanf("%d",c+i); scanf("%d",&v); if(v<5) { printf("%d\n",v);continue; } v-=5; sort(c,c+n); for(i=0;i<n-1;i++) { for(j=v;j>=c[i];j--) { if(dp[j]<dp[j-c[i]]+c[i]) { dp[j]=dp[j-c[i]]+c[i]; } } } printf("%d\n",v-dp[v]+5-c[n-1]); } return 0; }
HDU2546饭卡(变形01背包),布布扣,bubuko.com
标签:des style blog color java os io strong
原文地址:http://blog.csdn.net/fljssj/article/details/38486879