#P3168. [CQOI2015] 任务查询系统
[CQOI2015] 任务查询系统
Description
The laboratory is building a task management system for its supercomputer, and you are assigned to implement the query component.
Each task in the supercomputer is described by a triple , meaning it runs from second through second inclusive (the task is running at both second and second ), and its priority is . Multiple tasks may run at the same time, and their priorities may be the same or different.
The scheduler frequently asks the query system: among the tasks running at second , what is the sum of priorities of the smallest tasks (i.e., sort tasks by priority in ascending order and take the first )?
In particular, if is larger than the number of tasks running at second , return the sum of priorities of all tasks running at second . All parameters are integers, and the time range is within .
Input Format
The first line contains two space-separated positive integers and , the number of tasks and the time range, respectively.
The next lines each contain three space-separated positive integers (), describing one task.
The next lines each contain four space-separated integers , describing one query.
This problem is online. The parameter is computed by , where denotes the previous query’s result, with initial .
Output Format
Output lines, each containing one integer, the result of each query.
4 3
1 2 6
2 3 3
1 3 2
3 3 4
3 1 3 2
1 1 3 4
2 2 4 3
2
8
11
Hint
[Sample explanation]
.
.
.
Constraints
For of the testdata, , , , , and the form a permutation of to .
Note: On 2024-12-28 a hack testdata was added, post link.
Translated by ChatGPT 5
京公网安备 11011102002149号