#P30. [KBC001E] Difference
[KBC001E] Difference
Source
This problem is adapted from Long Long OJ. All rights reserved.
Description
Given , and sequences , find the shortest interval such that:
Output the length of the interval.
Output if no interval is found.
Input
The first line consists of two integers and .
The second line consists of integers .
The third line consists of integers .
Output
An integer that represents the minimum length of interval.
Output if no interval is found.
Samples
5 10
8 7 14 8 3
4 2 5 8 2
-1
5 14
11 22 3 15 6
21 20 17 22 136
1
Tips
Sample Explanation 2:
The interval is or , because and .
- .
- .