| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 57 | 17 | 17 | 34.694% |
In EGOI Airport, there are $N$ runways, numbered from $1$ to $N$. In this airport, for an airplane, it takes $K$ minutes to take off, and $L$ minutes to land. During a takeoff or landing of an airplane, a runway is occupied by the airplane for a duration of $K$ or $L$ minutes.
JOI-kun is working at EGOI Airport. His job is to arrange the schedule of takeoffs and landings for a contiguous time slot of $T$ minutes. The beginning of the time slot is time $0$. The time when $t$ minutes passed after the beginning of the time slot is time $t$. The end of the time slot is time $T$.
In the time slot, $M$ airplanes will arrive at EGOI Airport. They are numbered from $1$ to $M$. The ($1 ≤ i ≤ M$) will start landing at time $A_i$. But the runway used by airplane $i$ is not yet fixed. It will be fixed by JOI-kun. The schedule for the takeoffs is not fixed at all. JOI-kun will decide the number of airplanes which will take off, the time of a takeoff of each airplane, and the runway used by it.
In summary, the schedule has to obey the following rules.
JOI-kun wants to arrange the schedule so that it obeys the above rules, and the number of airplanes which will take off is maximized.
Write a program which, given the number of runways, the number of airplanes which will land, the length of the time slot, the time required for a takeoff, the time required for a landing, and the time when each airplane will start landing, calculates the maximum possible number of airplanes which will take off from EGOI Airport. If it is not possible to arrange the schedule so that it obeys the rules, your program should report it.
Read the following data from the standard input. Given values are all integers.
$N$ $M$ $T$ $K$ $L$
$A_1$ $A_2$ $\cdots$ $A_M$
Write one line to the standard output. The output should contain the maximum possible number of airplanes which will take off from EGOI Airport. If it is not possible to arrange the schedule so that it obeys the rules, output -1.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 7 | $N = 1$. |
| 2 | 12 | $N = 2$, $M ≤ 20$. |
| 3 | 17 | $N = 2$, $K = 2$, $L = 2$. |
| 4 | 28 | $N = 2$. |
| 5 | 11 | $N ≤ 100$. |
| 6 | 25 | No additional constraints. |
2 4 15 3 2 4 1 5 12
5
For example, if JOI-kun arranges the schedule as follows, 5 airplanes will take off.
It is not possible to arrange the schedule so that it obeys the rules and more than 5 airplanes will take off. Therefore, output 5.
This sample input satisfies the constraints of Subtasks 2, 4, 5, 6.
2 6 23 3 6 9 13 1 16 4 8
-1
It is not possible to arrange the schedule so that it obeys the rules. Therefore, output -1.
This sample input satisfies the constraints of Subtasks 2, 4, 5, 6.
1 5 20 2 1 2 8 11 15 5
7
This sample input satisfies the constraints of Subtasks 1, 5, 6.
2 6 13 2 2 7 0 1 10 7 4
5
This sample input satisfies the constraints of Subtasks 2, 3, 4, 5, 6.
4 4 14 2 3 5 6 3 9
21
This sample input satisfies the constraints of Subtasks 5, 6.
8 15 100 4 7 93 10 74 46 37 64 68 5 38 67 6 48 76 36 21
170
This sample input satisfies the constraints of Subtasks 5, 6.