#t413. 开餐馆
开餐馆
Opening a Restaurant
Problem Description
Xiaoming, a graduate of the School of Information, plans to start a business opening restaurants. There are candidate locations. Xiaoming wants to choose suitable locations to open some restaurants. The locations lie on a straight line. We use an integer sequence to represent their relative positions. Because of location, the profit of opening a restaurant differs. We use to denote the profit of opening a restaurant at . To avoid internal competition among his own restaurants, the distance between any two restaurants must be greater than . Please help Xiaoming choose a plan that maximizes the total profit.
Input Format
The first line of input is an integer , indicating there are test cases. The following test cases are given consecutively. Each test case has lines.
Line 1: total number of locations , and distance limit and .
Line 2: the positions of the locations (, integers, in ascending order).
Line 3: the restaurant profits at the locations (, integers).
Output Format
For each test case, output the maximum possible profit.
Sample Input 1
2
3 11
1 2 15
10 2 30
3 16
1 2 15
10 2 30
Sample Output 1
40
30
Constraints
; ; ; ; .
Source: "一本通在线评测" (Yiben Tong Online Judge).