#BS0000068. Vua bắn súng (Shooting King)
Vua bắn súng (Shooting King)
Shooting King
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Balloon starts at height and rises by per second. One balloon can be shot at each integer time . Shooting balloon at time incurs penalty . Minimize the maximum penalty.
Input
The first line contains . Each of the next lines contains .
Output
Print the minimum possible score.
Subtasks
- Subtask 1 — 20%: , , .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: , .
Example
Input
4
5 6
12 4
14 7
21 2
Output
23
Explanation
Shooting in order 3,4,2,1 gives maximum penalty 23.