Growing Vegetables is Fun 5
시간 제한5초메모리 제한1024 MB
비트닉 순서로 정렬된 2N개의 모종과 N개의 빨간 화분, N개의 파란 화분이 주어질 때, 같은 색 화분 N개가 연속하도록 배치하면서 화분과 모종 크기 차의 최댓값을 최소로 만든다.
문제
Bitaro, who has been enjoying gardening for many years, is planning to grow a plant called Bita-radish starting this spring.
Bitaro has prepared Bita-radish seedlings. The seedlings are numbered from to , and Bitaro plans to arrange them in this order for cultivation. The size of seedling () is . Bitaro wants every seedling to get enough sunlight, so the sizes of the seedlings satisfy the following conditions:
- .
- .
Note that seedling is the smallest and seedling is the largest.
Bitaro has also prepared red flowerpots and blue flowerpots, each of which also has a certain size. The size of the -th () red flowerpot is , and the size of the -th () blue flowerpot is . Bitaro plants one Bita-radish seedling in each of these total flowerpots, and arranges the flowerpots in a row so that seedlings are in this order.
Considering the appearance, the flowerpots must be arranged in a beautiful order. Here, a beautiful order means an arrangement of flowerpots such that there exist consecutive flowerpots with the same color. More precisely, an arrangement of flowerpots is said to be a beautiful order if and only if there exists an integer between and inclusive such that the colors of the flowerpots planted with seedlings are all the same.
When a seedling of size is planted in a flowerpot of size , the difficulty of cultivation for that pair is the absolute value . Bitaro’s workload in growing Bita-radish is the maximum difficulty of cultivation among the pairs of flowerpots and seedlings.
Write a program which, given the information about the Bita-radish seedlings and flowerpots, finds the minimum possible value of Bitaro’s workload when planting the seedlings so that the flowerpots are arranged in a beautiful order.
입력
The input is given from Standard Input in the following format:
출력
Print a single value ― the minimum possible value of Bitaro’s workload when planting the seedlings so that the flowerpots are arranged in a beautiful order ― in a single line to Standard Output.
제한
- .
- ().
- ().
- ().
- .
- .
- All input values are integers.