Exam Session
Limits: 2 sec., 256 MiB
Zenyk has \(n\) exams ahead. Zenyk’s energy amounts to exactly 100 percent, and it can be distributed among the exams in any way, including fractional parts of a percent. In total, at most 100 percent of energy can be spent on all the exams.
Exam number \(p\) is described by two integers \(l_p\) and \(r_p\): if 0 percent of energy is spent on it, Zenyk gets \(l_p\) points, and if 100 percent, \(r_p\) points. The points grow in proportion to the energy spent: if \(e\) percent of energy is spent on the exam, Zenyk gets
\[l_p + (r_p - l_p) \cdot \frac{e}{100}\]
points. For example, if \(l_p = 40\) and \(r_p = 90\), then 30 percent of energy gives \(40 + (90 - 40) \cdot \frac{30}{100} = 55\) points.
What is the maximum possible total number of points over all the exams?
Input
The first line contains one integer \(n\) – the number of exams.
Each of the next \(n\) lines contains two integers \(l_p\) and \(r_p\) – the points for the exam with no energy and with all the energy.
Output
In the only line, print one integer – the maximum possible total number of points. It can be proven that this total is always an integer.
Constraints
\(1 \le n \le 10^4\),
\(0 \le l_p \le r_p \le 100\).
The scoring consists of the following blocks:
1 point for each example from the statement,
15 points: \(n = 1\),
20 points: all differences \(r_p - l_p\) are equal,
25 points: all \(l_p = 0\),
38 points: no additional constraints.
You get the points for a block only if your program passes all tests of the block.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 3 40 90 70 80 25 75 | 185 |
| Input (stdin) | Output (stdout) |
|---|---|
| 3 60 100 10 50 0 30 | 110 |
Notes
In the first example, Zenyk can spend 60 percent of energy on the first exam and 40 percent on the third one. Then the points are \(40 + (90 - 40) \cdot \frac{60}{100} = 70\), 70 and \(25 + (75 - 25) \cdot \frac{40}{100} = 45\), 185 in total. A larger total cannot be obtained.
In the second example, Zenyk can spend 25 percent of energy on the first exam and 75 percent on the second one. Then the points are 70, 40 and 0, 110 in total. A larger total cannot be obtained.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|