시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB57171734.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.

  • It is not allowed that more than one airplane take off or land at the same time in the same runway. However, it is allowed that an airplane starts taking off or landing, just after another airplane finished taking off or landing in the same runway.
  • All takeoffs and landings should be finished in the time slot of $T$ minutes. Namely, it is not allowed for an airplane to start taking off or landing before time $0$. It is not allowed for an airplane to finish taking off or landing after time $T$.

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 ≤ N ≤ 100\,000$.
  • $1 ≤ M ≤ 100\,000$.
  • $1 ≤ T ≤ 1\,000\,000\,000 (= 10^9)$.
  • $1 ≤ K ≤ T$.
  • $1 ≤ L ≤ T$.
  • $0 ≤ A_i ≤ T - L$ ($1 ≤ i ≤ M$).

서브태스크

번호배점제한
17

$N = 1$.

212

$N = 2$, $M ≤ 20$.

317

$N = 2$, $K = 2$, $L = 2$.

428

$N = 2$.

511

$N ≤ 100$.

625

No additional constraints.

예제 입력 1

2 4 15 3 2
4 1 5 12

예제 출력 1

5

For example, if JOI-kun arranges the schedule as follows, 5 airplanes will take off.

  1. At time 0, an airplane will start taking off in the runway 1.
  2. At time 1, the airplane 2 will start landing in the runway 2.
  3. At time 4, the airplane 1 will start landing in the runway 2.
  4. At time 5, the airplane 3 will start landing in the runway 1.
  5. At time 6, an airplane will start taking off in the runway 2.
  6. At time 7, an airplane will start taking off in the runway 1.
  7. At time 9, an airplane will start taking off in the runway 2.
  8. At time 10, an airplane will start taking off in the runway 1.
  9. At time 12, the airplane 4 will start landing in the runway 2.

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

2 6 23 3 6
9 13 1 16 4 8

예제 출력 2

-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.

예제 입력 3

1 5 20 2 1
2 8 11 15 5

예제 출력 3

7

This sample input satisfies the constraints of Subtasks 1, 5, 6.

예제 입력 4

2 6 13 2 2
7 0 1 10 7 4

예제 출력 4

5

This sample input satisfies the constraints of Subtasks 2, 3, 4, 5, 6.

예제 입력 5

4 4 14 2 3
5 6 3 9

예제 출력 5

21

This sample input satisfies the constraints of Subtasks 5, 6.

예제 입력 6

8 15 100 4 7
93 10 74 46 37 64 68 5 38 67 6 48 76 36 21

예제 출력 6

170

This sample input satisfies the constraints of Subtasks 5, 6.

채점 및 기타 정보

  • 예제는 채점하지 않는다.