And the Winner Is... Ourselves!
InterviewTime limit4sMemory limit1024 MB
Given 11 problems that are all solved, choose the solving order that minimizes total penalty, where each problem contributes its finish time plus 20 times its wrong submissions.
- Level
Medium4 of 10
- Topics
- Greedy, Sorting, Math, Implementation
- Solved
- No attempts yet
Problem
Let us remind you how the total penalty for this contest is calculated.
- When you solve a problem at minutes, is added to your penalty, where is the number of incorrect verdicts (excluding compile errors) received on that problem.
- If you do not solve a problem before the contest ends, the incorrect verdicts on that problem are not counted toward the penalty.
Here is bad news for all of you: we, the problem setters, are planning to enter the competition and solve our own problems.
We know our problems very well, so we can solve all of them before the contest ends. Moreover, we can predict exactly how long each problem takes to solve and how many incorrect verdicts (excluding compile errors) we will get on each problem. Depending on the order in which we solve the problems, our total penalty can differ. What is the minimum penalty if we solve all the problems?
Input
The input consists of 11 lines. The -th line contains two space-separated integers and , where is the number of minutes required to solve the -th problem and is the number of incorrect verdicts on the -th problem.
For each , and . Also, .
Output
Output the minimum penalty if we solve all the problems.
Hint
The sample input does not necessarily reflect the actual difficulty of the problems.
The problem statement does not necessarily reflect the actual situation of the contest.