#P10980. 任务安排 4.1
任务安排 4.1
Background
This problem is an enhanced version of P10979, designed to help students gradually understand slope optimization DP.
Problem Description
There are tasks to be processed on a machine, forming a sequence. These tasks are numbered from to , so the order of the sequence is . The tasks are divided into several batches, and each batch contains several adjacent tasks. Starting from time , the tasks are processed batch by batch. The time required to complete task alone is . Before each batch starts, the machine needs a startup time , and the time required to finish this batch is the sum of the times required by all tasks in the batch.
Note: tasks in the same batch will be completed at the same time. The cost of each task equals its completion time multiplied by a cost coefficient .
Please determine a batching scheme that minimizes the total cost.
Input Format
The first line contains an integer .
The second line contains an integer .
The next lines each contain two integers and , meaning that the time required to complete task alone is , and its cost coefficient is .
Output Format
One line containing one integer, the minimum total cost.
5
1
1 3
3 2
4 3
2 3
1 4
153
Hint
For of the testdata, , , , .
Translated by ChatGPT 5