100%的数据,1≤n≤100000,1≤t≤100000000,1≤k≤100000。
var n,t,k,i,j,x,ans,max:longint; a,b:array[1..200000]of longint; procedure qsort(l,r:longint); var i,j,m,t:longint; begin i:=l;j:=r; m:=a[(l+r) div 2]; repeat while a[i]<m do inc(i); while a[j]>m do dec(j); if i<=j then begin t:=a[i]; a[i]:=a[j]; a[j]:=t; t:=b[i]; b[i]:=b[j]; b[j]:=t; inc(i); dec(j); end; until i>j; if l<j then qsort(l,j); if i<r then qsort(i,r); end; begin readln(n,t,k); for i:=1 to n do read(a[i]); for i:=1 to n do begin read(x); b[i]:=x; end; qsort(1,n); for i:=1 to k do a[n+i]:=a[i]+t; for i:=1 to k do b[n+i]:=b[i]; for i:=1 to n do begin ans:=b[i]; j:=i+1; while (a[j]<=a[i]+k) do begin ans:=ans+b[j]; inc(j); end; if ans>max then max:=ans; end; write(max); end.