# include & lt; stdio.h>
#include
#include
Int [1007], c w [1007], [1007] f [1007].
Int Max (int a, int b)
{
Return a> b? a:b;
}
Int main ()
{
Int qwe've, n, I, v, m, j.
The scanf (" % d ", & amp; Qwe);
For ('ve=1; Qw<=qwe; Qw++)
{memset (f 0, sizeof (f));
The scanf (" % d % d ", & amp; N, & amp; M);
for(i=1; i<=n; I++)
The scanf (" % d ", & amp; [I] c);
for(i=1; i<=n; I++)
The scanf (" % d ", & amp; W [I]);
For (I=n; i> 0; I -)
{
for(j=1; j<=m; J++)
{
If (j & gt; [I])
=cF [I] [j]=Max (f + 1] [I [I]] [j - c + w [I], [I + 1] [j] f);
Else if (f + 1] [I [j] & gt; F [I] [j])
[I] [j] f=f [I + 1] [j];
}
}
Printf (" % d \ n ", f [1] [m]);
}
return 0;
}
CodePudding user response:
The sample after tested, why not