#T243. 开餐馆

开餐馆

Description

Xiao Ming, a student from the School of Information, plans to start a restaurant business after graduation. There are currently nn locations to choose from, and Xiao Ming intends to select suitable spots to open some restaurants.
These nn locations are arranged in a straight line. Their relative positions are represented by an integer sequence m1,m2,,mnm_1, m_2, \dots, m_n.
Due to varying地段 (location) factors, the profits from opening restaurants differ. We use pip_i to denote the profit from opening a restaurant at mim_i. To avoid internal competition among his restaurants, the distance between any two restaurants must be greater than kk. Please help Xiao Ming select a plan that maximizes the total profit.

Input Format

The first line of input is an integer TT (1T10001 \leq T \leq 1000), indicating there are TT test cases. This is followed by TT consecutive test cases. Each test case consists of 33 lines:

  • Line 1: The total number of locations nn (n<100n < 100) and the distance restriction kk (k>0k > 0 and k<1000k < 1000);
  • Line 2: The positions of the nn locations m1,m2,,mnm_1, m_2, \dots, m_n (1000000>mi>01000000 > m_i > 0 and integers, listed in ascending order);
  • Line 3: The profits of opening restaurants at the nn locations p1,p2,,pnp_1, p_2, \dots, p_n (1000>pi>01000 > p_i > 0 and integers).

Output Format

For each test case, output the maximum possible profit.

2
3 11
1 2 15
10 2 30
3 16
1 2 15
10 2 30

40
30