Can anyone please tell me why my solution is not working for larger subtask,(while smaller is correct)
I made a dp to (i,j), where i denote number of stack inclused , while j represent number of plates need to choose.
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.flush();
ll t=1;
ll CaseN=1;
cin>>t;
while(t--)
{
ll ans=0;
ll n,k,A[100][100],p;
cin>>n>>k>>p;
ll c=0;
memset(A,0,sizeof(A));
for(ll i=1;i<=n;i++)
{
c=0;
for(ll j=1;j<=k;j++)
{
ll z;
cin>>z;
c+=z;
A[i][j]=c;
}
}
ll dp[101][101];
dp[0][0]=0;
for(ll i=1;i<=n;i++)
{
dp[i][0]=0;
}
for(ll i=1;i<=p;i++)
{
dp[0][i]=0;
}
for(ll i=1;i<=n;i++)
{
for(ll j=1;j<=p;j++)
{
ll cc=0;
for(ll l=0;l<=(k,j);l++)
{
if(j-l>=0)
{cc=max(cc,dp[i-1][j-l]+A[i][l]);}
}
dp[i][j]=cc;
}
}
ans=dp[n][p];
cout<<"Case #"<<CaseN<<": ";
CaseN++;
// print your ans below;
cout<<ans<<endl;
}
return 0;
}