From the back to the DP to complete backpack!
They initially were written + cut back support, but n too, noticed the title tag is dp, dp start trying to solve:
state equation: dp [i] = max ( (i> = a dp [ia] +? (? dp [ia] dp [ a]: 0): 0), max ((i> = b dp [ib] + (dp [ib] dp [b]:?? 0): 0), (i> ? = c dp [ic] + (dp [ic] dp [c]: 0?): 0)));
solution to a problem online is completely backpack: backpack full mastery of their own or not too deep!
DP AC Code 46ms:
int dp[5010];
int main(){
int n,a,b,c;
cin>>n>>a>>b>>c;
memset(dp,0,sizeof(dp));
int start = min(a,min(b,c));
dp[start] = 1;
dp[0] =1;
for(int i=start+1;i<=n;i++){
dp[i] = max((i>=a?dp[i-a]+(dp[i-a]?dp[a]:0):0),max((i>=b?dp[i-b]+(dp[i-b]?dp[b]:0):0),(i>=c?dp[i-c]+(dp[i-c]?dp[c]:0):0)));
}
cout<<dp[n];
return 0;
}