Pairs
InterviewTime limit1sMemory limit1024 MB
Split four given integers into two pairs and print the largest possible sum of the two pair products.
- Level
Easy3 of 10
- Topics
- Brute force, Math
- Solved
- No attempts yet
Problem
Four numbers , , , and are given. Split them into two pairs so that the sum of the products within the pairs is maximal.
For example, if the numbers are 2, 3, 4, and 5, the best split is and . The sum is .
Input
Four numbers , , , and are given. The absolute value of each number does not exceed 1000.
Output
Print the maximum sum.