#t308. 邮票问题(stamp)
邮票问题(stamp)
Stamps Problem
Problem Background
Special for beginners, ^_^
Problem Description
There are kinds of stamps with known denominations, and stamps of each kind. Using no more than stamps in total, from denomination 1 onward, what is the largest contiguous range of denominations you can form? (, , stamp denomination ).
Input Format
The first line: the values of , separated by a single space.
The second line: (the denominations), separated by single spaces.
Output Format
The maximum value of the contiguous range of denominations.
Sample Input
3 4
1 2 4
Sample Output
14
Constraints
1s, 1024KiB for each test case.