#P2224. [HNOI2001] 产品加工

    ID: 1198 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划,dp2001各省省选湖南背包

[HNOI2001] 产品加工

Description

A factory has two machines, A and B. Any product can be completed by either machine alone, or jointly by both machines. Due to machine performance and product characteristics, the time needed for different machines to process the same product differs; if both machines process a product simultaneously, the completed workload also differs.

One day, the factory receives nn product processing tasks, each with a different workload.

Your task: given the time t1t_1 to process a task on machine A, the time t2t_2 on machine B, and the time t3t_3 when both machines jointly process it, schedule the tasks to minimize the total time to finish all nn tasks.

Input Format

The first line contains an integer nn.

The next nn lines each contain three non-negative integers t1,t2,t3t_1,t_2,t_3, representing for the ii-th task the time required on machine A, on machine B, and when both machines jointly process it, respectively. If the given time t1t_1 or t2t_2 is 00, it means the task cannot be processed on that machine. If t3t_3 is 00, it means the task cannot be jointly processed by both machines.

Output Format

Output a single integer on one line, the minimum total time to complete all nn tasks.

5                            
2 1 0
0 5 0
2 4 1
0 0 3
2 1 1

9

Hint

For all testdata, 1n6×1031\le n\le 6\times 10^3, 0t1,t2,t350\le t_1,t_2,t_3\le 5.

Translated by ChatGPT 5