#d1302. 工作安排

工作安排

Job Scheduling

Problem Background

John has far too much work to do.

To keep the farm running efficiently, he must earn money from his work, and each job takes one unit of time.

His workday starts at time 00 and has 10910^9 units of time in total.

At any moment he may choose to do any one of the NN jobs numbered 11 to NN.

Each job has a deadline: for the ii-th job there is a deadline DiD_i, and if he completes it he earns a profit PiP_i.

Given the profits and deadlines, what is the maximum profit John can obtain?

Input Format

The first line contains an integer NN.

Lines 22 to N+1N+1 each contain two integers DiD_i and PiP_i.

Output Format

One number: the maximum profit.

Sample Input

3 
2 10 
1 5 
1 7

Sample Output

17

Constraints

1≤N≤1×1051 \le N \le 1 \times 10^5.

0≤Di,Pi≤1×1090 \le D_i, P_i \le 1 \times 10^9.