#P11274. 「Diligent-OI R1 D」DlgtTemplate
「Diligent-OI R1 D」DlgtTemplate
Background
A chessboard is made of wooden boards. This problem is about a chessboard, so...
Problem Description
There is a chessboard with row and cells, numbered . Each cell has a score written on it.
Now you need to choose some cells from left to right in order; you may also choose none. After choosing some cells, certain cells will clear the earliest cells among the currently chosen cells, turning them into unchosen cells, but you cannot go back and choose those cells again. In particular, if the number of chosen cells before this cell is less than , then this cell and the cells after it will not be cleared into unchosen cells.
Please find a left-to-right choosing plan that maximizes the sum of scores of the chosen cells.
Input Format
The first line contains , meaning the chessboard has cells.
The next line contains integers, representing the scores for cells .
The next line contains non-negative integers, representing the clearing counts for cells .
Output Format
You need to output a specific plan.
The first line outputs a non-negative integer , meaning you chose cells.
The second line outputs positive integers in increasing order, meaning the indices of the cells you chose from left to right. If you choose no cells, output an empty line.
The third line outputs , meaning your final answer.
Ns6 is very kind. If you cannot output the plan but your answer is correct, you can still get of the points. But in this case, you still need to output and the positive integers in increasing order.
6
1 1 4 5 1 4
1 0 0 2 1 1
4
1 2 3 4
9
13
-1 1 4 -5 -1 -4 1 9 -1 9 -8 -1 0
1 0 2 1 3 0 0 2 0 0 2 0 1
5
1 2 7 8 10
19
3
-1 -1 0
0 1 2
0
0
6
1 1 4 5 1 4
1 1 1 3 0 1
2
4 5
6
Hint
[Sample #1 Explanation]
First choose the first number . Although , since there are no chosen numbers before it, it will not clear anything.
Then choose the second number . Since , it will not clear anything.
Then choose the third number . Since , it will not clear anything.
Then choose the fourth number . Since , the first and second chosen numbers will be cleared into unchosen numbers.
At this time, the answer is . The method is not unique.
[Constraints and Notes]
For of the testdata, , , .
| Subtask ID | Special Property | Points | |
|---|---|---|---|
| None | |||
| None |
Translated by ChatGPT 5