#P2091. Fight against involution
Fight against involution
题目描述
点击这里查看pdf
MianKing chose a course in this semester. There are students in this course, and everyone needs to write a final paper. Let denote the word count of the i-th student's final paper.
The i-th student has a lower bound and an upper bound on the number of words in his final paper so that
The grade rule of this course is very amazing. The grade of the i-th student is , is the number of satisfies that .
Every student wants to achieve the highest possible grade, so under the optimal decision will equal to for the i-th student.
But MianKing found an interesting thing: let's assume that . Under the optimal decision are all equal to and the grades of the students are all . But if everyone only writes 1000 words in their final papers, their grades are still all and they can use the time they save to play games.
Now to fight against involution, MianKing wants to decide for each student, and his plan has to satisfy the following conditions:
-
For each student, his grade cannot be less than that in the original plan.
-
Minimize the sum of .
You need help MianKing calculate the minimum value of
输入格式
The first line has one integer .
Then there are lines, the i-th line has two integers .
输出格式
Output the minimum value of .
样例
3
1 10000
1 10000
1 10000
3
4
1 2
2 2
2 4
3 4
10
提示
Form 2020ICPC济南站