Woburn Challenge 2017-18 Finals Round - Senior Division
The Great Cow-Monkey War of 2017 has left Scarberia in a fragile and unstable state. Interspecies tension is at an all-time high, and both sides are working relentlessly to rebuild their economies, social systems, and militias. Little do the cows and monkeys know that amidst the turmoil, the world is at risk of being taken over by an even more dangerous foe — a group of aliens known as the Party of Extraterrestrial Gangsters (or PEG for short)! PEG has decided that it's the perfect time to divide and conquer Scarberia by exploiting its current internal hostilities. Fortunately, Bo Vine and the Head-Monkey have learned of the impending invasion in time, and an important realization has dawned on them: now is not the time to engage in petty quarrels with one another. All of Scarberia must unite, at least temporarily, to face an even greater evil. The animals have thus formed a truce, and started to plan for the upcoming war!
With an overall battle formation decided, the cows and monkeys are now ready to fight against the incoming alien invaders! …Well, almost. You see, the commanders realized that it is not too effective to simply line up large platoons of uniformly cows or uniformly monkeys. They must work together at a more local scale, with each cow and monkey taking immediate advantage of each others' strengths and weaknesses. As such, the commanders have decided to pair up cows and monkeys to form individual combat units on the battlefield.
Between the united armies, there are
A combat unit is most effective when the skill levels of its two members
don't differ too greatly. More formally, we can define the combat skill
differential of a given unit to be the absolute difference between the
combat skill levels of the two animals making up that unit. For a given
pairing of the
Subtasks
In test cases worth
In test cases worth another
In test cases worth another
Input Specification
The first line of input consists of a single integer,
The second line consists of
The third line consists of
Output Specification
Output a single integer, the minimum possible value of
Sample Input
4
5 1 9 1
2 7 4 6
Sample Output
3
Sample Explanation
One possible optimal arrangement is to pair:
- cow
with monkey (a combat skill differential of ) - cow
with monkey (a combat skill differential of ) - cow
with monkey (a combat skill differential of ) - cow
with monkey (a combat skill differential of )
The maximum of these differentials is
Comments