#25. 比较数组和
比较数组和
Compare Array Sums
Background
In a programming exercise, you need to compare the sums of elements in two arrays.
Problem Description
Start with two integer arrays, and , each of length . Consider the sum of the values in each array. Return the array which has the largest sum. In the event of a tie, return array .
Input Format
The input is given from standard input in the following format.
A single line containing four integers , representing the two elements of array and the two elements of array , respectively.
Output Format
Output to standard output in the following format.
Output the array with the larger sum in the format
[x, y].
Sample
1 2 3 4
[3, 4]
3 4 1 2
[3, 4]
1 1 1 2
[1, 2]
Sample Explanation
Sample 1: Array is with sum . Array is with sum . Since , array is returned, which is [3, 4].
Sample 2: Array is with sum . Array is with sum . Since , array is returned, which is [3, 4].
Sample 3: Array is with sum . Array is with sum . Since , array is returned, which is [1, 2].
Constraints
Time limit: 1 second, Memory limit: 1024KB.