P27656 [洛谷] [JOI 2024 Final] Marathon Race 2
提高+
题目描述

Problem Description

JOI Avenue is a road running east-west with a length of \( L \) meters. Location \( l \) is \( l \) meters (\( 0 \leq l \leq L \)) from the western end of the road.

This year, the first marathon event was held on JOI Avenue. The rules of this marathon are different from the usual ones and are conducted as follows:

  • There are \( N \) balls placed on the road, with the \( i \)-th (\( 1 \leq i \leq N \)) ball at location \( X_i \). Multiple balls can be placed at the same location.
  • Participants start from a designated starting point, collect all \( N \) balls, and if they reach the designated finishing point within the time limit, they complete the race. However, if they drop any collected balls, they are disqualified.

The starting point, finishing point, and time limit have not been announced yet, but \( Q \) possible scenarios have been disclosed. For the \( j \)-th (\( 1 \leq j \leq Q \)) scenario, the starting point is location \( S_j \), the finishing point is location \( G_j \), and the time limit is \( T_j \) seconds.

Rie is one of the athletes in the marathon. It takes her 1 second to pick up a ball, and it takes \( x+1 \) seconds to run 1 meter while holding \( x \) balls.

Given the information about JOI Avenue, the balls, and the scenarios, write a program to determine for each scenario whether Rie can complete the race.

Input Format

The first line contains two integers \( N \) and \( L \).

The second line contains \( N \) integers separated by spaces: \( X_1, X_2, \ldots, X_N \).

The third line contains an integer \( Q \).

The next \( Q \) lines each contain three integers \( S_j, G_j, T_j \), representing the \( j \)-th scenario.

Output Format

Output \( Q \) lines. The \( j \)-th (\( 1 \leq j \leq Q \)) line should output "Yes" if Rie can complete the \( j \)-th scenario, otherwise output "No".

Sample Input and Output

Input Sample #1

3 100
30 80 30
3
0 100 403
0 100 300
0 100 262

Output Sample #1

Yes
Yes
No

Input Sample #2

3 100
30 80 30
3
0 0 403
0 0 300
0 0 262

Output Sample #2

Yes
No
No

Input Sample #3

6 100
0 50 100 0 50 100
4
20 70 600
70 20 600
10 40 600
40 10 600

Output Sample #3

No
Yes
No
Yes

Notes/Hints

For all input data, the following conditions are satisfied:

  • \( 1 \leq N \leq 5 \times 10^5 \)
  • \( 1 \leq L \leq 5 \times 10^5 \)
  • \( 0 \leq X_i \leq L \) (\( 1 \leq i \leq N \))
  • \( 1 \leq Q \leq 5 \times 10^5 \)
  • \( 0 \leq S_j \leq L \) (\( 1 \leq j \leq Q \))
  • \( 0 \leq G_j \leq L \) (\( 1 \leq j \leq Q \))
  • \( 1 \leq T_j \leq 5 \times 10^5 \) (\( 1 \leq j \leq Q \))

The detailed subtask additional restrictions and scores are as follows:

Subtask Additional Restrictions Score
1 \( N \leq 7, Q \leq 10, S_j = 0, G_j = 0 \) (\( 1 \leq j \leq Q \)) 7
2 \( N \leq 7, Q \leq 10 \) 7
3 \( N \leq 14, Q \leq 10 \) 10
4 \( N \leq 100, Q \leq 10 \) 28
5 \( N \leq 2000, Q \leq 10 \) 10
6 \( N \leq 2000 \) 19
7 No additional restrictions 19
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 100 30 80 30 3 0 100 403 0 100 300 0 100 262
样例输出
Yes Yes No