NOI '19 P3 - Sequence

View as PDF

Submit solution

Points: 25 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem types

Given two positive integer sequences {a1,a2,,an} and {b1,b2,,bn} of length n, you must find two sequences {c1,c2,,cK} and {d1,d2,,dK} of length K satisfying the following conditions:

  1. 1c1<c2<<cKn.
  2. 1d1<d2<<dKn.
  3. |{c1,c2,,cK}{d1,d2,,dK}|L.

Subject to these conditions, maximize i=1Kaci+i=1Kbdi.

Input Specification

The first line contains an integer T, indicating the number of test cases.

For each test case:

The first line contains three integers n, K, L.

The second line contains n integers, indicating {a1,a2,,an}.

The third line contains n integers, indicating {b1,b2,,bn}.

Constraints

For all test cases, T10, 1n106, 1LKn2×105, 1ai,bi109.

Test Casenn
1~3103×105
4~518
6~730
8~10150
11~162000
17~212×105
22~25106

Output Specification

Output one integer on one line, the answer.

Sample Input 1

Copy
5
1 1 1
7
7
3 2 1
4 1 2
1 4 2
5 2 1
4 5 5 8 4
2 1 7 2 7
6 4 1
1 5 8 3 2 4
2 6 9 3 1 7
7 5 4
1 6 6 6 5 9 1
9 5 3 9 1 4 2

Sample Output 1

Copy
14
12
27
45
62

Comments

There are no comments at the moment.