4SUM
InterviewTime limit2sMemory limit512 MB
Pick one number from each of four sets of up to 500 integers so the four numbers sum to zero.
- Level
Medium4 of 10
- Topics
- Hash map
- Solved
- No attempts yet
Problem
You are given four sets of integers. Choose one integer from each set so that the four chosen numbers add up to . You can assume that exactly one such choice exists.
Input
The first line contains four integers , , , and , separated by spaces. They give the sizes of the four sets, and each one satisfies .
The next lines each contain one element of a set. Every element is an integer no smaller than and no larger than . The elements of the first set come first, then the elements of the second set, then the third set, then the fourth set.
Output
Print the four integers whose sum is on one line, separated by spaces. Order them the way their sets appear in the input.