#K211. Potion Reduction Challenge

    ID: 24664 Type: Default 1000ms 256MiB

Potion Reduction Challenge

Potion Reduction Challenge

In this problem, you are given (n) knights each with an initial number of potions given by a sequence (a_0, a_1, \ldots, a_{n-1}). The knights must have at most (p) potions after a reduction. For any knight with more than (p) potions, you are forced to reduce at least (a_i - p) potions so that the final count does not exceed (p). You may reduce additional potions from any knight, but a knight's potion count cannot become negative. Determine whether it is possible to perform exactly (k) units of reduction in total while satisfying all these constraints.

inputFormat

The first line of input contains three integers (n), (p), and (k) where (n) is the number of knights, (p) is the maximum allowed potions per knight after reduction, and (k) is the exact total reduction required. The second line contains (n) space-separated integers (a_0, a_1, \ldots, a_{n-1}) representing the initial potion counts.

outputFormat

Output a single line containing either "Yes" if it is possible to perform exactly (k) units of reduction while guaranteeing that no knight ends up with negative potions and every knight has at most (p) potions, or "No" otherwise.## sample

3 10 7
5 8 6
Yes