#P5785. [SDOI2012] 任务安排
[SDOI2012] 任务安排
Problem Description
There are tasks to be processed on a machine, and they form 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 consecutive tasks. Starting from time , the tasks are processed batch by batch. The time required to finish task alone is . Before each batch starts, the machine needs a startup time , and the time needed to finish this batch is the sum of the times of all tasks in the batch.
Note that tasks in the same batch will be completed at the same time. The cost of each task is its completion time multiplied by a cost coefficient .
Please determine a batching plan that minimizes the total cost.
Input Format
The first line contains an integer . The second line contains an integer .
The next lines each contain a pair of integers and , meaning that the time required to finish task alone is , and its cost coefficient is .
Output Format
One line containing an integer, representing the minimum total cost.
5
1
1 3
3 2
4 3
2 3
1 4
153
Hint
Constraints: For of the testdata, , , , .
Translated by ChatGPT 5