标签:
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int t,n,k,a[110],b[110],c[110],i,j; scanf("%d",&t); while(t--) { scanf("%d %d",&n,&k); for(i = 1 ; i <= n ; i++) scanf("%d",&a[i]); for(i=1; i<=n; i++) { scanf("%d",&b[i]); c[i]=b[i]; } for(i=1; i<=n; i++) for(j=1; j<=i-1; j++) if(a[i] - a[j] > k) c[i]=max(c[i],(c[j]+b[i])); sort(c+1,c+n+1); printf("%d\n",c[n]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/biu-biu-biu-/p/5724693.html