페이지가 로드되지 않나요? 여기를 눌러보면 고쳐질 수도 있어요.
Placeholder

#5916
서브태스크
채점 보류

Collecting Stamps 3 2초 512MB

문제

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

[제한]

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


출력

Write the answer in one line to the standard output.


부분문제

번호 점수 조건
#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

입력
625
347172123
1171710810
출력
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

입력
520
4581317
182315710
출력
5

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


예제3

입력
419
371214
2054
출력
0

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


예제4

입력
1087
9233338424445626778
1591727315312918946
출력
5

출처

JOI 2020

역링크