B - Checkout Assistant
Crawling in process...Crawling failedTime Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Submit Status Practice CodeForces 19B
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
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
Input
Output
8
Input
Output
111
思路:简单01背包,不过要注意优化,就是题目中有说偷的时间只要1秒,所以当时间大于n秒时,他可以都所以物品,因此只要更新到 n就可以得到正确答案了。
仔细想想,记忆化搜索好像也行。