Under construction

Still being built. Things may change

And the Winner Is... Ourselves!

Interview

Time limit4sMemory limit1024 MB

Summary
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 TT minutes, T+20VT+20V is added to your penalty, where VV 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 ii-th line contains two space-separated integers D_iD\_i and V_iV\_i, where D_iD\_i is the number of minutes required to solve the ii-th problem and V_iV\_i is the number of incorrect verdicts on the ii-th problem.

For each ii, 1≤D_i1 \leq D\_i and 0≤V_i≤1 0000 \leq V\_i \leq 1\ 000. Also, ∑_i=111D_i≤300\sum\_{i=1}^{11} D\_i \leq 300.

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.

Examples1

  1. Example 1

    Input
    20 1
    20 0
    20 3
    10 0
    10 0
    10 0
    30 0
    30 0
    30 0
    20 0
    20 10
    
    Expected output
    1360