#P11103. [ROI 2022] 挑战 (Day 2)
[ROI 2022] 挑战 (Day 2)
Background
Translated from ROI 2022 D2T4.
In the design class at the Sirius Educational Center, a team designed an industrial robot. These robots will put parts into containers numbered from to . Each container can hold at most parts.
There are robots in total. Initially, robot has parts. Also, robot has a working range determined by two numbers and , meaning it can only put parts into containers with indices from to (inclusive). Robots try to put as many parts as possible into the containers.
Robots are of two types. If a robot has type , then its working range always stays unchanged. If a robot has type , it can change its working range. If the container numbered is designated as the most important container, then the working range of every type robot will expand so that this range contains container . In other words, for a type robot , its working range will become .
Problem Description
For each from to , compute the maximum number of parts that the robots can put into the containers when container is considered the most important container.
Input Format
This problem has multiple test cases. The first line contains an integer , the number of test cases.
For each test case, the first line contains two integers and , the number of containers and the number of robots.
The next line contains integers , the capacities of the containers.
Each of the next lines contains four integers , describing the robot's working range, the number of parts it initially carries, and the robot type.
Output Format
For each test case, output integers, representing the answers for all from to .
1
4 3
3 3 2 2
1 2 2 0
3 3 3 0
2 2 4 1
8 7 7 8
Hint
For of the testdata, , , , , , .
| Subtask | Score | Other special properties | ||
|---|---|---|---|---|
| For all robots with , or | ||||
Translated by ChatGPT 5