문제
Farmer John is growing () plants of asparagus on his farm! However some of his plants have genetic differences, so some plants will grow faster than others. The initial height of the th plant is inches, and after each day, the th plant grows by inches.
FJ likes some of his plants more than others, and he wants some specific plants to be taller than others. He gives you an array of distinct values containing all integers from to and he wants the th plant to have exactly other plants that are taller than it. Find the minimum number of days so that FJ's request is satisfied, or determine that it is impossible.
입력
The first will consist of an integer , denoting the number of independent test cases .
The first line of each test case consists of an integer .
The second line consists of integers denoting the initial height of the th plant in inches.
The third line consists of integers denoting the number of inches the th plant grows each day.
The fourth line consists of distinct integers denoting the array that FJ gives you.
It is guaranteed that the sum of over all test cases does not exceed .
출력
Output lines, the answer to each test case on a different line. If it is not possible, output .
예제 입력 1
6
1
10
1
0
2
7 3
8 10
1 0
2
3 6
10 8
0 1
2
7 3
8 9
1 0
2
7 7
8 8
0 1
2
7 3
8 8
1 0
예제 출력 1
0
3
2
5
-1
-1
예제 입력 2
2
5
7 4 1 10 12
3 4 5 2 1
2 1 0 3 4
5
4 10 12 7 1
3 1 1 4 5
2 4 3 1 0
예제 출력 2
4
7
점수
Input 3: Inputs 4-5: and Inputs 6-8: Inputs 9-13: No additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인