PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000136. Divan mua sô-cô-la (Divan and a Store)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Divan mua sô-cô-la (Divan and a Store)
Divan and a Store
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are chocolate bars costing . Divan buys only bars priced within the inclusive range and spends at most in total. Each bar may be bought at most once. Maximize the number of bars purchased.
Input
The first line contains . The next line contains prices .
Output
Print the maximum number of bars.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
6 3 5 10
1 2 3 4 5 6
Output
2
Explanation
Only bars costing are allowed. The two cheapest cost ; buying all three costs , hence the maximum is .