include[HTML_REMOVED]
using namespace std;
int t, n, m, a[1005], b[1005], f[1005];
int main()
{
cin >> t;
while(t–)
{
memset(f, 0, sizeof(f));
cin >> n >> m;
for (int i = 1; i <= n; i)
cin >> a[i];
for (int i = 1; i <= n; i)
cin >> b[i];
int maxn = INT_MIN;
f[1] = b[1];
for (int i = 2; i <= n; i)
{
f[i] = b[i];
for (int j = i - 1; j >= 0; j–)
if (a[i] - a[j] > m) f[i] = max(f[i], f[j] + b[i]);
}
for (int i = 1; i <= n; i)
maxn = max(maxn, f[i]);
cout << maxn << endl;
}
return 0;
}
咦,你好low欧,连解释都不会
至少比你好
大佬解释一下呗
菜鸡你好!