#P16229. [蓝桥杯 2026 省 A] 外卖配送

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

[蓝桥杯 2026 省 A] 外卖配送

Problem Description

In the lunchtime rush at a food delivery station, courier Xiao Lan is staring at the screen showing NN pending orders. These orders must be delivered strictly in the fixed order listed by the system; they cannot be rearranged or skipped. To complete the task smoothly, Xiao Lan plans to split the NN orders into several batches for delivery.

There are MM different types of vehicles at the station. Each vehicle has two attributes: average travel time AiA_i and box crowding coefficient BiB_i. For each batch, Xiao Lan may independently choose the most suitable vehicle from the MM types based on the number of orders in that batch.

Suppose a batch contains LL orders, and Xiao Lan chooses vehicle type ii. Then the total time for this batch consists of the following three parts:

  1. Travel time: L×AiL \times A_i seconds.
  2. Pickup/packing time: due to squeezing in the box, arranging LL orders requires handling L(L1)2\frac{L(L-1)}{2} pairs of squeezing relationships. Each pair takes BiB_i seconds, for a total of L(L1)2×Bi\frac{L(L-1)}{2} \times B_i seconds.
  3. Return time: delivering in batches incurs extra return cost. When processing the first batch, since Xiao Lan is assumed to have already loaded at the station and can depart directly, this part takes 00 seconds. Starting from the second batch, each time a new batch is started, a fixed XX seconds must be spent to return to the station to load the next batch.

Now, please help Xiao Lan plan an optimal batching scheme and compute the minimum total time needed to finish delivering all NN orders.

Input Format

The first line contains three integers NN, MM, and XX, representing the total number of orders, the number of vehicle types, and the fixed time cost.

The next MM lines each contain two integers AiA_i and BiB_i, representing the average travel time and the box crowding coefficient of the ii-th vehicle type.

Output Format

Output one integer, the minimum total time required to complete delivery of all NN orders (in seconds).

5 2 40
10 8
2 20
118

Hint

Sample Explanation

One optimal plan is to split into 22 batches:

Stage Details Time
Batch 11 (22 orders, choose vehicle 22) Travel 2×2=42 \times 2 = 4; Pickup/packing 2×12×20=20\frac{2 \times 1}{2} \times 20 = 20 2424 seconds
Return Fixed time cost 4040 seconds
Batch 22 (33 orders, choose vehicle 11) Travel 3×10=303 \times 10 = 30; Pickup/packing 3×22×8=24\frac{3 \times 2}{2} \times 8 = 24 5454 seconds
Total 118\mathbf{118} seconds

Constraints

For 30%30\% of the testdata, 1N,M1001 \le N, M \le 100.

For all testdata, 1N,M50001 \le N, M \le 5000, 1X,Ai,Bi1091 \le X, A_i, B_i \le 10^9.

Translated by ChatGPT 5