Preparando MOJI

Checkout Assistant

1000ms 262144K

Description:

Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other items from his trolley. To steal one item Bob needs exactly 1 second. What is the minimum amount of money that Bob will have to pay to the checkout assistant? Remember, please, that it is Bob, who determines the order of items for the checkout assistant.

Input:

The first input line contains number n (1 ≤ n ≤ 2000). In each of the following n lines each item is described by a pair of numbers ti, ci (0 ≤ ti ≤ 2000, 1 ≤ ci ≤ 109). If ti is 0, Bob won't be able to steal anything, while the checkout assistant is occupied with item i.

Output:

Output one number — answer to the problem: what is the minimum amount of money that Bob will have to pay.

Sample Input:

4
2 10
0 20
1 5
1 3

Sample Output:

8

Sample Input:

3
0 1
0 10
0 100

Sample Output:

111

Informação

Codeforces

Provedor Codeforces

Código CF19B

Tags

dp

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 08:27:08

Relacionados

Nada ainda