Codeforces Round 917 (Div. 2) |
---|
Finished |
You have an array of integers $$$a_1, a_2, \ldots, a_n$$$ of length $$$n$$$. On the $$$i$$$-th of the next $$$d$$$ days you are going to do exactly one of the following two actions:
Your score is equal to $$$0$$$ in the beginning. Note that on each day you should perform exactly one of the actions above: you cannot skip a day or perform both actions on the same day.
What is the maximum score you can achieve at the end?
Since $$$d$$$ can be quite large, the sequence $$$b$$$ is given to you in the compressed format:
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^3$$$) — the number of test cases.
The first line of each test case contains three integers $$$n$$$, $$$k$$$ and $$$d$$$ ($$$1 \le n \le 2000$$$, $$$1 \le k \le 10^5$$$, $$$k \le d \le 10^9$$$) — the length of the array $$$a$$$, the length of the sequence $$$v$$$ and the number of days you are going to perform operations on.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le n$$$) — the array $$$a$$$.
The third line of each test case contains $$$k$$$ integers $$$v_1, v_2, \ldots, v_k$$$ ($$$1 \le v_i \le n$$$) — the sequence $$$v$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2000$$$ and the sum of $$$k$$$ over all test cases doesn't exceed $$$10^5$$$.
For each test case, output one integer: the maximum score you can achieve at the end of the $$$d$$$-th day.
53 4 41 2 31 3 2 36 2 36 1 2 4 1 56 65 1 10 5 0 5 051 1 1113 4 61 2 31 3 2 3
4 3 0 1 5
In the first test case, the sequence $$$b$$$ is equal to $$$[1, 3, 2, 3, 1, 3, 2, 3, \ldots]$$$ and one of the optimal solutions for this case is as follows:
It can be shown that it is impossible to score more than $$$4$$$, so the answer is $$$4$$$.
In the second test case, the sequence $$$b$$$ is equal to $$$[6, 6, 6, 6, \ldots]$$$. One of the ways to score $$$3$$$ is to perform operations of the first type on the $$$1$$$-st and the $$$3$$$-rd days and to perform an operation of the second type on the $$$2$$$-nd day.
Name |
---|