#25. 比较数组和

    ID: 25 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-1gesp1条件结构数学基础

比较数组和

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, aa and bb, each of length 22. 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 aa.

Input Format

The input is given from standard input in the following format.

A single line containing four integers a1,a2,b1,b2a_1, a_2, b_1, b_2, representing the two elements of array aa and the two elements of array bb, 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 aa is [1,2][1, 2] with sum 1+2=31+2=3. Array bb is [3,4][3, 4] with sum 3+4=73+4=7. Since 7>37 > 3, array bb is returned, which is [3, 4].

Sample 2: Array aa is [3,4][3, 4] with sum 3+4=73+4=7. Array bb is [1,2][1, 2] with sum 1+2=31+2=3. Since 7>37 > 3, array aa is returned, which is [3, 4].

Sample 3: Array aa is [1,1][1, 1] with sum 1+1=21+1=2. Array bb is [1,2][1, 2] with sum 1+2=31+2=3. Since 3>23 > 2, array bb is returned, which is [1, 2].

Constraints

Time limit: 1 second, Memory limit: 1024KB.