#QHD0000055. Ngân sách và khoản hoàn tiền (Trouble of 13-Dots)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Ngân sách và khoản hoàn tiền (Trouble of 13-Dots)
Trouble of 13-Dots
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
You have a shopping budget of dollars and distinct items. Item has listed price and favour score . Each item may be bought at most once and buying nothing is allowed.
A credit-card promotion gives a refund of 200 dollars only when the total listed expense strictly exceeds . No refund is given for a total at most . Your final amount paid after any refund must not exceed . Maximize the sum of favour scores. In particular, a listed expense exactly equal to receives no refund.
Input
The first line contains . Each of the next lines contains the item price and favour score .
Output
Print the greatest achievable total favour within the effective budget.
Subtasks
Scoring groups are independent. All constraints listed for a group apply simultaneously.
- Subtask 1 (20%): , , , .
- Subtask 2 (30%): , , , .
- Subtask 3 (50%): , , , .
Examples
Input
500 4
100 2
100 3
200 3
400 4
Output
8
Explanation
With budget , no refunded purchase is affordable. Items priced cost and yield favour; no better feasible selection exists.