#P11274. 「Diligent-OI R1 D」DlgtTemplate

    ID: 11959 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP洛谷原创Special Judge背包 DP洛谷月赛

「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 11 row and nn cells, numbered 1n1\sim n. Each cell has a score aia_i 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 bib_i 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 bib_i, 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 nn, meaning the chessboard has nn cells.

The next line contains nn integers, representing the scores a1ana_1\sim a_n for cells 1n1\sim n.

The next line contains nn non-negative integers, representing the clearing counts b1bnb_1\sim b_n for cells 1n1\sim n.

Output Format

You need to output a specific plan.

The first line outputs a non-negative integer kk, meaning you chose kk cells.

The second line outputs kk 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 ansans, meaning your final answer.

Ns6 is very kind. If you cannot output the plan but your answer is correct, you can still get 40%40\% of the points. But in this case, you still need to output kk and the kk 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 11. Although b1=1b_1=1, since there are no chosen numbers before it, it will not clear anything.

Then choose the second number 11. Since b2=0b_2=0, it will not clear anything.

Then choose the third number 44. Since b3=0b_3=0, it will not clear anything.

Then choose the fourth number 55. Since b4=2b_4=2, the first and second chosen numbers will be cleared into unchosen numbers.

At this time, the answer is 4+5=94+5=9. The method is not unique.

[Constraints and Notes]

For 100%100\% of the testdata, 1n30001\le n\le3000, ai108|a_i|\le10^8, 0bin0\le b_i\le n.

Subtask ID nn\le Special Property Points
00 2020 None 2525
11 500500 2020
22 30003000 bi>0b_i>0 55
33 bi=0b_i=0
44 ai=1a_i=1 1515
55 None 3030

Translated by ChatGPT 5