Amplitude has installed the new hit arcade game, Killer Queen! Killer Queen is a 5v5 team game where teams of five players compete against each other. In the game, each team has one player serve as the queen and the other four players serve as drones. Before the game starts, each team can pick which player serves as the queen.
Conveniently, there are 10 people who wish to play Killer Queen, so they will split into two teams to play against each other. Each person has a skill level when playing as the queen and a (possibly different) skill level when playing as a drone. The strength of a team is the sum of the skill levels of the players depending on their assigned roles. The imbalance of the match between the two teams is equal to the absolute value of the difference of the strengths of the two teams.
To make the game as fun as possible, the 10 people coordinate to minimize the imbalance of the match. Compute the minimum possible imbalance.
Constraints
All skill levels are positive integers between
Input Specification
The first line of input contains ten integers, the skill levels of players
The second line of input contains ten integers, the skill levels of players
Output Specification
Output the minimum possible imbalance possible.
Sample Input 1
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
Sample Output 1
0
Sample Explanation 1
If players 3, 4, 5, 6, and 7 form a team with player 6 as the queen, their skill level is
Note that there are other arrangements which also result in an imbalance of
Sample Input 2
31 41 59 26 53 58 98 93 23 84
27 18 28 18 28 45 90 45 23 53
Sample Output 2
0
Sample Explanation 2
An imbalance of
Sample Input 3
1 2 4 8 16 32 64 128 256 512
1 2 4 8 16 32 64 128 256 512
Sample Output 3
31
Sample Explanation 3
An imbalance of
Comments