#P10207. [JOI 2024 Final] 马拉松比赛 2 / Marathon Race 2

[JOI 2024 Final] 马拉松比赛 2 / Marathon Race 2

Problem Description

JOI Avenue is an east-west road with length LL meters. A location ll is the point that is l (0lL)l\ (0 \leq l \leq L) meters from the west end of the road.

This year, a marathon event is held on JOI Avenue for the first time. The rules of this marathon are different from usual, and it is run in the following way:

  • There are NN balls placed on the road. The i (1iN)i\ (1 \leq i \leq N)-th ball is placed at location XiX_{i}. There may be multiple balls placed at the same location.
  • A participant starts from the designated start point, collects all NN balls, and is considered to have finished if they reach the designated goal point within the designated time limit. However, if they put down any collected ball on the ground, they will be disqualified.

The start point, goal point, and time limit of this event have not been announced yet, but QQ possible plans have been announced. In the j (1jQ)j\ (1 \leq j \leq Q)-th plan, the start point is location SjS_{j}, the goal point is location GjG_{j}, and the time limit is TjT_{j} seconds.

Rie is one of the athletes in the marathon event. It takes her 11 second to pick up one ball, and running 11 meter on the road while carrying xx balls takes x+1x+1 seconds.

Given the information about JOI Avenue, the balls, and the plans, write a program to determine for each plan whether Rie can finish.

Input Format

The first line contains two integers N,LN, L.

The second line contains NN integers X1,X2,,XNX_1, X_2, \ldots ,X_N separated by spaces.

The third line contains one integer QQ.

The next QQ lines each contain three integers Sj,Gj,TjS_j, G_j, T_j, representing the jj-th plan.

Output Format

Output QQ lines. On the j (1jQ)j\ (1 \leq j \leq Q)-th line, output Yes if Rie can finish in the jj-th plan; otherwise output No.

3 100
30 80 30
3
0 100 403
0 100 300
0 100 262
Yes
Yes
No
3 100
30 80 30
3
0 0 403
0 0 300
0 0 262
Yes
No
No
6 100
0 50 100 0 50 100
4
20 70 600
70 20 600
10 40 600
40 10 600
No
Yes
No
Yes

Hint

For all input data, the following conditions are satisfied:

  • 1N5×1051 \leq N \leq 5\times 10^5
  • 1L5×1051 \leq L \leq 5\times 10^5
  • 0XiL (1iN)0 \leq X_{i} \leq L\ (1 \leq i \leq N)
  • 1Q5×1051 \leq Q \leq 5\times 10^5
  • 0SjL (1jQ)0 \leq S_{j} \leq L\ (1 \leq j \leq Q)
  • 0GjL (1jQ)0 \leq G_{j} \leq L\ (1 \leq j \leq Q)
  • 1Tj5×105 (1jQ)1 \leq T_{j} \leq 5\times 10^5\ (1 \leq j \leq Q)

The detailed additional constraints and scores for subtasks are shown in the table below.

Subtask Additional Constraints Score
1 $N \leq 7, Q \leq 10, S_{j}=0, G_{j}=0\ (1 \leq j \leq Q)$ 7
2 N7,Q10N \leq 7, Q \leq 10
3 N14,Q10N \leq 14, Q \leq 10 10
4 N100,Q10N \leq 100, Q \leq 10 28
5 N2000,Q10N \leq 2000, Q \leq 10 10
6 N2000N \leq 2000 19
7 No additional constraints.

Translated by ChatGPT 5