#P6879. [JOI 2020 Final] 集邮比赛 3 / Collecting Stamps 3

    ID: 7744 远端评测题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP2020区间 DPJOI(日本)

[JOI 2020 Final] 集邮比赛 3 / Collecting Stamps 3

Problem Description

Given a circle with circumference LL, starting from a point, there are NN black-and-white bear statues numbered from 11 to NN. The ii-th statue is located XiX_i meters clockwise from the starting point. If you do not collect this black-and-white bear statue within TiT_i seconds, it will make a “wuppuppuppu” sound and then explode.

Now JOI-kun is at the starting point. He can move 11 meter per second, and he may move either clockwise or counterclockwise.

JOI-kun wants to know: what is the maximum number of black-and-white bear statues he can collect?

Input Format

The first line contains two integers N,LN, L, representing the number of statues and the circumference of the circle.
The second line contains NN integers XiX_i, representing how many meters clockwise each statue is located from the starting point.
The third line contains NN integers TiT_i, representing within how many seconds each statue must be collected.

Output Format

Output one integer on a single line, representing the answer.

6 25
3 4 7 17 21 23
11 7 17 10 8 10
4
5 20
4 5 8 13 17
18 23 15 7 10

5
4 19
3 7 12 14
2 0 5 4

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

5

Hint

Explanation for Sample 1

JOI-kun can collect 44 black-and-white bear statues using the following strategy:

Direction Distance Total Time Which Statue Can Collect
Counterclockwise 22 meters 22 seconds 66 \sqrt{}
44 seconds 55
Clockwise 77 meters 1111 seconds 11
11 meter 1212 seconds 22 ×\times
33 meters 1515 seconds 33 \sqrt{}

Explanation for Sample 2

JOI-kun can just keep walking counterclockwise.

Explanation for Sample 3

JOI-kun cannot obtain any statue.

Constraints

This problem uses bundled testdata.

  • Subtask 1 (5 pts): N12N \le 12, L200L \le 200, Xi200X_i \le 200.
  • Subtask 2 (10 pts): N15N \le 15.
  • Subtask 3 (10 pts): L200L \le 200, Ti200T_i \le 200.
  • Subtask 4 (75 pts): No special restrictions.

For 100%100\% of the testdata:

  • 1N2001 \le N \le 200.
  • 2L1092 \le L \le 10^9.
  • 1Xi<L1 \le X_i < L.
  • Xi<Xi+1X_i < X_{i+1}.
  • 0Ti1090 \le T_i \le 10^9.

Notes

Translated from The 19th Japanese Olympiad in Informatics, Final Round C Stamp Rally 3.

Translated by ChatGPT 5