#P3212. [HNOI2011] 任务调度
[HNOI2011] 任务调度
Description
There are tasks and two machines, A and B. Each task must be processed on both machines.
The -th task requires time on machine A and time on machine B. The goal is to finish all tasks on both A and B while minimizing the total time to complete all tasks. However, some tasks have restrictions on whether they must be processed on A first or on B first. Based on this, all tasks are divided into three categories:
- The task must be processed on machine A first, then on machine B.
- The task must be processed on machine B first, then on machine A.
- The task has no restriction and may be processed on machine A first or on machine B first.
Given each task’s category and its processing times on machines A and B, find the minimum total time required to finish all tasks according to the rules.
Input Format
The first line contains a single positive integer , the number of tasks.
Each of the next lines contains three space-separated positive integers , denoting the category of task (categories , , and are as defined above) and the processing times of task on machines A and B, respectively.
Output Format
Output a single integer, the minimum total time required to finish all tasks.
3
3 5 7
1 6 1
2 2 6
14
Hint
Sample 1 Explanation:
One optimal scheduling plan is:
On machine A, schedule the tasks in order: Task , task , task ;
On machine B, schedule the tasks in order: Task , task , task ,
so the total time required to finish all tasks is .
Constraints:
For of the testdata, it is guaranteed that , , , and the number of tasks with does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号