시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB109635756.436%

문제

Republic of IOI, where JOI-kun lives, is famous for a large lake. Today, a stamp rally event takes place around the lake.

There are N types of stamps situated around the lake. These stamps are numbered from 1 to N, in clockwise order. The perimeter of the lake is L, and the i-th stamp (1 ≤ i ≤ N) is located at Xi meters clockwise from the starting point of the stamp rally.

Each participant stands at the starting point of the stamp rally. After the rally starts, each participant can move around the lake, both clockwise and counter-clockwise. Each participant can collect the i-th stamp (1 ≤ i ≤ N) only if they arrive at where the i-th stamp is located within Ti seconds (inclusive) since the rally starts.

JOI-kun is a participant of the stamp rally. He takes 1 second to move 1 meter. You can ignore all the other times which he takes.

Write a program that, given the number of types of stamps, the perimeter of the lake, where each stamp is located, and the time until which JOI-kun can collect each stamp, calculates the maximum number of types of stamps he can collect in total.

입력

Read the following data from the standard input. Given values are all integers.

N L
X1 . . . XN
T1 . . . TN

출력

Write the answer in one line to the standard output.

제한

  • 1 ≤ N ≤ 200.
  • 2 ≤ L ≤ 1 000 000 000.
  • 1 ≤ Xi < L (1 ≤ i ≤ N).
  • Xi < Xi+1 (1 ≤ i ≤ N − 1).
  • 0 ≤ Ti ≤ 1 000 000 000 (1 ≤ i ≤ N).

서브태스크

번호배점제한
15

N ≤ 12, L ≤ 200, Ti ≤ 200 (1 ≤ i ≤ N).

210

N ≤ 15.

310

L ≤ 200, Ti ≤ 200 (1 ≤ i ≤ N).

475

No additional constraints.

예제 입력 1

6 25
3 4 7 17 21 23
11 7 17 10 8 10

예제 출력 1

4

JOI-kun can collect 4 types of stamps as described below:

  1. Walk 2 meters counter-clockwise. He can collect the 6th stamp as it is 2 minutes since the rally starts.
  2. Walk 2 meters counter-clockwise. He can collect the 5th stamp as it is 4 minutes since the rally starts.
  3. Walk 7 meters clockwise. He can collect the 1st stamp as it is 11 minutes since the rally starts.
  4. Walk 1 meter clockwise. He cannot collect the 2nd stamp as it is 12 minutes since the rally starts.
  5. Walk 3 meters clockwise. He can collect the 3rd stamp as it is 15 minutes since the rally starts.

It is impossible for JOI-kun to collect 5 or more stamps, so the answer is 4

예제 입력 2

5 20
4 5 8 13 17
18 23 15 7 10

예제 출력 2

5

JOI-kun can collect all the stamps by walking around the lake counter-clockwise.

예제 입력 3

4 19
3 7 12 14
2 0 5 4

예제 출력 3

0

Unfortunately, JOI-kun cannot collect any stamps, no matter how he moves.

예제 입력 4

10 87
9 23 33 38 42 44 45 62 67 78
15 91 7 27 31 53 12 91 89 46

예제 출력 4

5

채점 및 기타 정보

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