49. Sum and Average
Foundation1000 ms256 MBSolved by 0%
Print the sum of the array, then its average rounded down to a whole number, separated by a single space.
Rounding down means -2.4 becomes -3, not -2.
Constraints - `1 ≤ n ≤ 100000` - `-1000000 ≤ a[i] ≤ 1000000`
Input
The first line contains an integer n.
The second line contains n space-separated integers.
Output
Print two integers on one line, separated by a single space, the sum, then the average rounded DOWN.
Input5
1 2 3 4 5
Output15 3
Notedivides exactly
Input4
1 2 3 5
Output11 2
Notehas a remainder, so the average rounds down
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.