#include <iostream> using namespace std; int main() { int n; n=8; int dp[n+2][n+2]; for(int i=0;i<=n+1;i++) for(int j=0;j<=n+1;j++) dp[i][j]=0; int b[]={0,1, 5, 8, 9, 10, 17, 17, 20}; for(int i=1;i<=n+1;i++ ) for(int j=1;j<=n+1;j++) { if(j>=i) dp[i][j]=max(dp[i-1][j],b[i]+dp[i][j-i]); else dp[i][j]=dp[i-1][j]; } cout<<dp[n+1][n+1]; return 0; }
b[i]
i
n+1 = 9
b
b[i-1]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)