#K57207. Collecting Flowers
Collecting Flowers
Collecting Flowers
In this problem, you are given (n) fields, each containing a certain number of flowers. Piglet collects flowers from fields with even indices (0-indexed), and Winnie collects from fields with odd indices. Your task is to compute the total number of flowers collected by Piglet and Winnie respectively. Specifically, if the flower abundance in the (i^{th}) field is (a_i), then Piglet collects (\sum_{i \equiv 0 , (\text{mod }2)} a_i) and Winnie collects (\sum_{i \equiv 1 , (\text{mod }2)} a_i).
inputFormat
The input consists of two lines. The first line contains a single integer (n) representing the number of fields. The second line contains (n) space-separated integers, where the (i^{th}) integer represents the number of flowers in the (i^{th}) field.
outputFormat
Output two integers separated by a space. The first integer is the total number of flowers collected by Piglet (from fields with even indices) and the second integer is the total number of flowers collected by Winnie (from fields with odd indices).## sample
6
3 8 7 2 5 1
15 11