#C9845. Garden Fruit Optimization
Garden Fruit Optimization
Garden Fruit Optimization
You are given a garden that is divided into n zones. Each zone produces a certain number of fruits per day. However, due to storage or consumption limitations, the maximum number of fruits that can be available is capped by an integer \(L\) (the fruit limit). Additionally, a parameter \(d\) is provided to indicate the number of days to simulate, though the garden’s daily production is fixed and the fruit limit applies based on a single day's production.
Your task is to compute the maximum number of fruits available in the garden. In other words, if each zone produces \(a_i\) fruits per day, then the total daily production is \(\sum_{i=1}^{n} a_i\). The answer is given by:
[ \text{result} = \min\left(\sum_{i=1}^{n} a_i,, L\right). ]
Note: Although the simulation spans \(d\) days, the available fruits are determined solely by a single day's production limited by \(L\).
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains three space-separated integers:
n
(the number of zones),L
(the fruit limit), andd
(the number of days, which does not affect the result). - The second line contains
n
space-separated integers representing the number of fruits produced by each zone per day.
You may assume that all input values are positive integers.
outputFormat
Output a single integer to stdout: the maximum number of fruits available in the garden, computed as \(\min\left(\sum_{i=1}^{n} a_i, L\right)\).
## sample5 100 3
10 20 30 40 50
100
</p>