#P3308. [SDOI2014] LIS
[SDOI2014] LIS
Description
Given a sequence , each element has a deletion cost and an additional attribute . Delete some elements so that the length of the longest increasing subsequence of decreases by at least , 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 , the number of test cases. The next lines describe the test cases.
For each test case, the first line contains an integer , the number of elements in .
The next three lines each contain integers: , , , satisfying , and all are pairwise distinct.
Output Format
For each test case, output two lines. The first line contains two integers , denoting the total deletion cost and the number of deleted elements, respectively. The second line contains integers, the positions in 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 , , , etc., are all valid solutions, but yields the lexicographically smallest sequence of values.
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号