The first time to wash a 01 backpack, incredibly fooled 7 test points.
Then I found it was not as simple as I thought.
DP[I][J][K] for the first I first placed on the first J CD, occupy the J disc of the K minutes can be installed in the number of songs
/*id:modengd1prog:rockerslang:c++*/#include <iostream> #include <stdio.h> #include <memory.h> Using namespace Std;int Main () { freopen ("rockers.in", "R", stdin); Freopen ("Rockers.out", "w", stdout); int n,t,m; int i,j,k; int a[25]; int dp[25][25][25]= {0}; F[I][J][K] The first song is installed on the J CD scanf ("%d%d%d", &n,&t,&m); for (I=1; i<=n; i++) scanf ("%d", &a[i]); For (I=1, i<=n; i++) for (j=1; j<=m; j + +) for (k=0; k<=t; k++) { dp[i][j][k]=dp[i-1][j][k] ; if (K>=a[i]) Dp[i][j][k]=max (dp[i][j][k],dp[i-1][j][k-a[i]]+1); if (J>1&&t>=a[i]) Dp[i][j][k]=max (dp[i][j][k],dp[i-1][j-1][t-a[i]]+1); } cout<<dp[n][m][t]<<endl; return 0;}
Usaco raucous rockers