#P16001. [ICPC 2020 NAC] ICPC Camp

[ICPC 2020 NAC] ICPC Camp

题目描述

John is a leading organizer of this year’s North America ICPC training camp. The camp lasts several days. On each day, there will be a lecture introducing two problems: one classical problem and one creative problem. Each problem can only be introduced once during the entire camp. Every problem has an integer difficulty level.

John knows that the lecture on each day should not be too overwhelming. Therefore, the sum of the difficulties of the two problems in a single day shall not exceed some fixed value. Also, the two problems on each day should be roughly on the same level. Let dd be the absolute difference between the difficulties of the two problems introduced on any given day. The maximum of all of the dds, defined as DD, should be as small as possible.

If John chooses problems well and arranges them wisely, what is the smallest DD he can achieve for the nn days of the ICPC training camp?

输入格式

The first line of input contains four space-separated integers nn, pp, qq (1n,p,q21051 \le n, p, q \le 2 \cdot 10^5, nmin(p,q)n \le \min(p, q)) and ss (0s1090 \le s \le 10^9), where nn is the number of days of the camp, pp is the number of classical problems, qq is the number of creative problems, and ss is the maximum sum of difficulties on any given day.

Each of the next pp lines contains an integer xx (0x1090 \le x \le 10^9). These are difficulties of the pp classical problems.

Each of the next qq lines contains an integer yy (0y1090 \le y \le 10^9). These are difficulties of the qq creative problems.

输出格式

Output a single integer, which is the smallest DD John can achieve, or 1-1 if there is no way John can select problems for the nn training days.

4 5 5 10
1
3
3
4
9
0
2
5
7
8
4
4 4 4 15
1
5
10
12
1
3
10
14
13
4 4 4 10
1
12
5
10
1
10
3
14
-1