Banner Home Page Web Contests Problems Ranklist Status Statistics

B. Checkout Assistant

Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 524288/262144K (Java/Other)
Total Submission(s) : 0   Accepted Submission(s) : 0
Problem 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
<p>The first input line contains number <span class="tex-span"><i>n</i></span> (<span class="tex-span">1¡Ü<i>n</i>¡Ü2000</span>). In each of the following <span class="tex-span"><i>n</i></span> lines each item is described by a pair of numbers <span class="tex-span"><i>t</i><sub class="lower-index"><i>i</i></sub></span>, <span class="tex-span"><i>c</i><sub class="lower-index"><i>i</i></sub></span> (<span class="tex-span">0¡Ü<i>t</i><sub class="lower-index"><i>i</i></sub>¡Ü2000,1¡Ü<i>c</i><sub class="lower-index"><i>i</i></sub>¡Ü10<sup class="upper-index">9</sup></span>). If <span class="tex-span"><i>t</i><sub class="lower-index"><i>i</i></sub></span> is 0, Bob won't be able to steal anything, while the checkout assistant is occupied with item <span class="tex-span"><i>i</i></span>.</p>
 

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

Sample Input
4 2 10 0 20 1 5 1 3 3 0 1 0 10 0 100
 

Sample Output
8 111
 

Source
Codeforces
 

Statistic | Submit | Back