#P3308. [SDOI2014] LIS

[SDOI2014] LIS

Description

Given a sequence AA, each element AiA_i has a deletion cost BiB_i and an additional attribute CiC_i. Delete some elements so that the length of the longest increasing subsequence of AA decreases by at least 11, while minimizing the sum of deletion costs, and output the solution.

If there are multiple solutions, output the one whose deleted elements’ additional attributes, after sorting, form the lexicographically smallest sequence.

Input Format

The input contains multiple test cases.

The first line contains an integer TT, the number of test cases. The next 4T4T lines describe the test cases.

For each test case, the first line contains an integer NN, the number of elements in AA.

The next three lines each contain NN integers: A1AnA_1\sim A_n, B1BnB_1\sim B_n, C1CnC_1\sim C_n, satisfying 1Ai,Bi,Ci1091\le A_i,B_i,C_i \le 10^9, and all CiC_i are pairwise distinct.

Output Format

For each test case, output two lines. The first line contains two integers S,MS, M, denoting the total deletion cost and the number of deleted elements, respectively. The second line contains MM integers, the positions in AA of the deleted elements, in increasing order.

1
6
3 4 4 2 2 3
2 1 1 1 1 2
6 5 4 3 2 1
4 3
2 3 6

Hint

[Sample explanation]

Deleting (A2,A3,A6)(A_2,A_3,A_6), (A1,A6)(A_1,A_6), (A2,A3,A4,A5)(A_2,A_3,A_4,A_5), etc., are all valid solutions, but (A2,A3,A6)(A_2,A_3,A_6) yields the lexicographically smallest sequence of CC values.

For 100%100\% of the testdata, 1N7001\le N\le 700, 1T51\le T\le 5.

Translated by ChatGPT 5