#K59862. Maximum Bundles of Coins
Maximum Bundles of Coins
Maximum Bundles of Coins
You are given an integer K and a series of piles of coins. In each pile, you can form a bundle if the number of coins in that pile is at least K. The number of bundles that can be formed from a pile is exactly \(\lfloor\frac{pile}{K}\rfloor\) (using \(\lfloor \cdot \rfloor\) to denote the floor function). Your task is to compute the total number of bundles you can form from all piles.
Example:
- For K = 6 and piles
[3, 5, 2, 7, 1, 8]
, the maximum number of bundles is2
because only two piles (7 and 8) yield one bundle each (\(7//6 = 1\) and \(8//6 = 1\)). - For K = 4 and piles
[4, 8, 12, 16]
, the result is10
since \(4//4=1\), \(8//4=2\), \(12//4=3\), \(16//4=4\) and the total is1+2+3+4 = 10
.
Note that if a pile does not contain enough coins to form even a single bundle, it contributes 0
to the total count.
inputFormat
The input is provided in a single line from stdin. The first integer is K, the minimum number of coins needed to form a bundle. This is followed by one or more integers, each representing the number of coins in a pile.
For example:
6 3 5 2 7 1 8
outputFormat
Output a single integer to stdout denoting the maximum number of bundles that can be formed from the provided piles.
For instance, the sample input above should produce:
2## sample
6 3 5 2 7 1 8
2