#P16300. [蓝桥杯 2026 省 Python C 组] 智能产线排程优化

    ID: 18315 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 显示难度普及 上传者: 标签>动态规划 DP排序2026蓝桥杯省赛

[蓝桥杯 2026 省 Python C 组] 智能产线排程优化

Problem Description

A smart manufacturing factory has two fully identical automated production lines that can work in parallel, denoted as A and B. The factory has received NN production orders at the same time.

For the ii-th order (1iN1 \le i \le N), you are given three parameters:

  • Processing time pip_i: the time required to process this order on either production line.
  • Delivery deadline did_i: the order must be completed before (and including) hour did_i.
  • Profit rir_i: the profit the factory can obtain if the order is completed on time.

Both production lines start running from hour 00 and are independent of each other. For any production line:

  • At any moment, at most one order can be processed.
  • Once an order starts processing, it must be completed continuously without interruption.
  • There is no switching time between adjacent orders.

The factory may choose any subset of these NN orders to produce. For each chosen order, you need to decide:

  • Whether to assign it to production line A or production line B.
  • Its processing order on the assigned production line.

All chosen orders must be completed within their respective delivery deadlines. Compute the maximum total profit the factory can obtain.

Input Format

The first line contains a positive integer NN, representing the number of orders.

The next NN lines each contain three positive integers pi,di,rip_i, d_i, r_i, representing the processing time, delivery deadline, and profit of the ii-th order.

Output Format

Output one line containing an integer, representing the maximum total profit that can be obtained.

4
3 4 10
3 5 12
2 3 6
4 7 15
43
5
3 4 10
2 3 7
4 6 20
3 7 12
5 8 18
60

Hint

Sample Explanation 1

The information of the four orders is as follows:

Order ID 11 22 33 44
Processing time pip_i 33 22 44
Delivery deadline did_i 44 55 33 77
Profit rir_i 1010 1212 66 1515

One optimal schedule is:

  • Production line A: process order 33 first, then order 22.
  • Production line B: process order 11 first, then order 44.

The completion details are:

  • Production line A:

    • Order 33 is processed during hour 020 \sim 2, with completion time 22, satisfying 2d3=32 \le d_3 = 3.
    • Order 22 is processed during hour 252 \sim 5, with completion time 55, satisfying 5d2=55 \le d_2 = 5.
  • Production line B:

    • Order 11 is processed during hour 030 \sim 3, with completion time 33, satisfying 3d1=43 \le d_1 = 4.
    • Order 44 is processed during hour 373 \sim 7, with completion time 77, satisfying 7d4=77 \le d_4 = 7.

All four orders can be completed on time, and the total profit is:

6+12+10+15=436 + 12 + 10 + 15 = 43

Sample Explanation 2

The total processing time of the five orders is:

3+2+4+3+5=173 + 2 + 4 + 3 + 5 = 17

With the latest delivery deadline being 88, the two production lines can provide at most 1616 units of processing time in the time interval [0,8][0, 8], so it is impossible to schedule all orders and finish them on time.

One optimal plan is to give up order 22 and choose orders {1,3,4,5}\{1, 3, 4, 5\}. The schedule is:

  • Production line A: process order 33 first, then order 44.
  • Production line B: process order 11 first, then order 55.

The corresponding completion times are:

  • Order 33: completion time is 44, satisfying 4d3=64 \le d_3 = 6.
  • Order 44: completion time is 77, satisfying 7d4=77 \le d_4 = 7.
  • Order 11: completion time is 33, satisfying 3d1=43 \le d_1 = 4.
  • Order 55: completion time is 88, satisfying 8d5=88 \le d_5 = 8.

These four orders can all be completed on time, so the total profit is:

20+12+10+18=6020 + 12 + 10 + 18 = 60

It can be proven that there is no feasible plan with profit greater than 6060, so the answer is 6060.

Constraints and Notes on Test Cases

  • For 30%30\% of the test cases, N15N \le 15.
  • For 60%60\% of the test cases, N50N \le 50, and di300d_i \le 300.
  • For all test cases, 1N2001 \le N \le 200, 1pi501 \le p_i \le 50, pidi1000p_i \le d_i \le 1000, 1ri100001 \le r_i \le 10000.

Translated by ChatGPT 5