The test data for this problem was rigged and has been fixed since the beginning of the contest, with all non-AC solutions having been rejudged. We apologize for the inconvenience.
has been participating in rated contests recently!
Starting out with rating, and volatility, he has participated in contests in order, with him getting th place out of participants, for all in the range .
After participating in a contest, his rating and volatility will update according to the following formulas: \(\newcommand{\floor}[1]{\lfloor #1 \rfloor}\)
\(R_{new} = \floor{500 × \sqrt{\frac{b_i}{a_i}} × \frac{V_{old}}{2000} + R_{old} × \frac{2000 - V_{old}}{2000}}\)
\(V_{new} = \floor{V_{old} + \sqrt{|R_{old} - R_{new}|} - 100}\)
\(\floor{x}\) denotes the symbol. denotes the absolute value symbol.
Assume that these formulas are used in sequential order.
, as always, is dissatisfied with his results, and is currently trying to abuse his power to rig the contests! A rig can be defined as unrating a contest as a whole, causing the contest to no longer affect his rating at all.
Given all of this information, can you help
figure out the maximum rating that he can gain?Input Specification
On the first line, three space-separated integers , , and . , \((0 \le R \le 5 × 10^5)\), . The next lines contain two space-separated integers and . .
Output Specification
A single integer, representing the maximum rating that
can end up with.Subtasks
Subtask | Points | Description |
---|---|---|
1 | 30 | . |
2 | 70 | No further constraints. |
Sample Input
4 1200 385
2 100
100 100
25 350
15 50
Sample Output
1682
Explanation
The optimal move is to unrate the second contest and the last contest.
After the first contest, 1649
and his volatility will be 306
.
After the second contest, 1682
and his volatility will be 211
.
Comments