#P8454. 「SWTR-8」补题计划
「SWTR-8」补题计划
Description
Little A has a total of problems that he has not made up. After evaluation, he thinks the difficulty of problem is .
At the same time, he has an evaluation value for his own level. His level may fluctuate, so will change.
Little A believes that making up problems whose difficulty is close to his level (difference no more than ) brings a benefit ; on the contrary, if the difference is too large (difference greater than ), it wastes time and causes a negative benefit . Therefore, the benefit of making up problem is
$$\begin{cases} inc & |x_i - w| \leq b_1 \\ 0 & b_1 < |x_i - w| \leq b_2 \\ dec & |x_i - w| > b_2 \\ \end{cases}$$It is guaranteed that and .
In addition, Little A has some problems he likes and dislikes. If he does not make up any liked problem, or if he makes up any disliked problem, he will be unhappy.
Little A will choose a consecutive segment of problems (by index) to make up. He wants to maximize the sum of benefits of all chosen problems, and he must not be unhappy after finishing. Please tell him this maximum value.
All queries are independent of each other.
Input Format
The first line contains an integer , indicating the Subtask number of this test point.
The second line contains seven integers , where is the number of events.
The third line contains integers .
The following lines describe events. Each event takes either one line or three lines:
- First an integer .
- If , then the next two integers represent the number of liked problems and disliked problems; the next line contains integers , the indices of liked problems; the next line contains integers , the indices of disliked problems. It is guaranteed that any .
- If , then the next integer is the new level evaluation value.
Output Format
For each event with , output one line with one integer, the answer.
0
7 7 1 2 3 2 -3
1 0 6 4 8 2 2
1 1 1
4
3
1 2 0
3 4
1 2 0
2 4
2 1064
1 1 0
1
2 5
1 2 2
2 7
4 6
1
2
4
-3
0
Hint
"Sample Explanation"
When , the benefits of each problem are .
In the first query, you must make up problem , and you must not make up problem . The optimal choice is , with benefit .
In the second query, you must make up problem or problem . The optimal choice is , with benefit .
In the third query, you must make up problem or problem . The optimal choice is , with benefit .
When , the benefit of every problem is .
In the fourth query, you must make up problem . The optimal choice is , with benefit .
When , the benefits of each problem are .
In the fifth query, you must make up problem or problem , and you must not make up problems and . The optimal choice is , with benefit .
"Constraints and Notes"
This problem uses bundled tests.
- Subtask #1 (7 points): .
- Subtask #2 (12 points): . Depends on Subtask #1.
- Subtask #3 (20 points): . Depends on Subtask #2.
- Subtask #4 (25 points): .
- Subtask #5 (11 points): , .
- Subtask #6 (15 points): . Depends on Subtask #4.
- Subtask #7 (10 points): no special constraints. Depends on Subtask #3, #5, #6.
For of the data:
- .
- , , and is no more than half of the upper bound of .
- .
- , , .
- It is guaranteed that and are increasing, and within one query each index appears at most once.
"Help and Tips"
Please pay attention to I/O optimization.
"Problem Source"
- Sweet Round 8 C
- Idea & Solution: tzc_wk.
- Tester: Alex_Wei & chenxia25。
Translated by ChatGPT 5
>
京公网安备 11011102002149号