PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000121. Sưu tầm nhiều mệnh giá tiền xu (Coin Collector)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Sưu tầm nhiều mệnh giá tiền xu (Coin Collector)
Coin Collector
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A bank has denominations with . When withdrawing an arbitrary positive integer , it repeatedly gives the largest coin not exceeding the remaining amount until fully paid. Maximize the number of distinct denominations obtained in one withdrawal.
Input
The first line has . The second line contains strictly increasing denominations .
Output
Print the maximum number of distinct denominations.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
6
1 3 6 8 15 20
Output
4
Explanation
With withdrawal , the bank gives , totaling four different denominations. The greedy payment rule prevents simultaneously including all other denominations.