#K15191. Maximum Fruit Pairs
Maximum Fruit Pairs
Maximum Fruit Pairs
You are given ( n ) trees, where each tree ( i ) has ( a_i ) fruits. Your task is to determine the maximum number of fruit pairs that can be collected from all trees. A fruit pair consists of two fruits. Thus, the maximum number of pairs is given by the formula:
[ \left\lfloor \frac{\sum_{i=1}^{n} a_i}{2} \right\rfloor ]
Note that you must use all the available fruits optimally to form the pairs.
inputFormat
The input consists of two lines:
- The first line contains a single integer ( n ), the number of trees.
- The second line contains ( n ) space-separated integers ( a_1, a_2, \dots, a_n ), where ( a_i ) represents the number of fruits on the ( i)-th tree.
outputFormat
Output a single integer representing the maximum number of fruit pairs that can be collected.## sample
4
1 2 3 4
5
</p>