PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000291. Giá mua bình phương (Square Price)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Giá mua bình phương (Square Price)
Square Price
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A shop has product types, each with units available. Buying units of type costs , where may be zero. Find the maximum total number of units within budget .
Input
First line: . Second line: integers .
Output
Print one integer: the maximum achievable value.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input 1
3 9
4 1 9
Output 1
3
Explanation
One unit of type 1 and two of type 2 cost 8. The four cheapest marginal prices sum to 13.
Input 2
10 1000
2 15 6 5 12 1 7 9 17 2
Output 2
53
Explanation
53 units fit within the budget; 54 do not.