PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000297. Sagheer và chợ Nubia (Sagheer and Nubian Market)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Sagheer và chợ Nubia (Sagheer and Nubian Market)
Sagheer and Nubian Market
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are distinct souvenirs indexed from 1 to , with base prices . When exactly items are bought, the actual price of each selected item is . Each item can be bought at most once. With budget , maximize the item count and then minimize total cost for that count.
Input
First line: . Second line: integers .
Output
Print two integers : the maximum count and its minimum cost. Print 0 0 if no item is affordable.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input 1
3 11
2 3 5
Output 1
2 11
Explanation
For k=2, prices are 4,7,11; choose the first two, costing 11. Three items cost 28.
Input 2
1 7
7
Output 2
0 0
Explanation
The sole item costs 8 if one item is bought.