Logo
(追記) (追記ここまで)

31625번 - Marathon Race 2 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 1024 MB129383329.730%

문제

JOI Avenue is a road of length $L$ in an east-west direction. The place of $l$ meters (0ドル ≤ l ≤ L$) from the west end on the road is called ”position $l$”.

The first marathon race in JOI Avenue is going to be held this year. The race has a different regulation from normal one, which is described in the following:

  • Before the race, $N$ balls are located on the road. The $i$-th ball (1ドル ≤ i ≤ N$) is located at position $X_i$. Multiple balls may be located at the same position.
  • The participant starts at the designated position.
  • The participant collects all $N$ balls and finishes at the designated position. When this is achieved within the designated time limit, one completes the race. However, once the participant collect a ball, they must not put the ball on the road, otherwise they will be disqualified from the race.

The starting and finishing position, and the time limit, are not yet announced, but it is known that they are chosen from $Q$ scenarios. The $j$-th scenario (1ドル ≤ j ≤ Q$) is that, the participant starts at position $S_j,ドル finishes at position $G_j,ドル and the time limit is $T_j$ seconds.

Rie is participating in the marathon race. She spends 1ドル$ second to collect 1ドル$ ball. She spends $x + 1$ seconds to move 1ドル$ meter, where $x$ is the number of balls she is carrying.

Write a program which, given the information of JOI Avenue, the positions of balls, and the scenarios, determines whether there exists a way for Rie to complete the race, for each scenario.

입력

Read the following data from the standard input.

$N$ $L$

$X_1$ $X_2$ $\cdots$ $X_N$

$Q$

$S_1$ $G_1$ $T_1$

$S_2$ $G_2$ $T_2$

$\vdots$

$S_Q$ $G_Q$ $T_Q$

출력

Write $Q$ lines to the standard output. On the $j$-th line (1ドル ≤ j ≤ Q$), output Yes if there exists a way for Rie to complete the race for scenario $j,ドル and No otherwise.

제한

  • 1ドル ≤ N ≤ 500,円 000$.
  • 1ドル ≤ L ≤ 500,円 000$.
  • 0ドル ≤ X_i ≤ L$ (1ドル ≤ i ≤ N$).
  • 1ドル ≤ Q ≤ 500,円 000$.
  • 0ドル ≤ S_j ≤ L$ (1ドル ≤ j ≤ Q$).
  • 0ドル ≤ G_j ≤ L$ (1ドル ≤ j ≤ Q$).
  • 1ドル ≤ T_j ≤ 500,円 000$ (1ドル ≤ j ≤ Q$).
  • Given values are all integers.

서브태스크

번호배점제한
17

$N ≤ 7,ドル $Q ≤ 10,ドル $S_j = 0,ドル $G_j = 0$ (1ドル ≤ j ≤ Q$).

27

$N ≤ 7,ドル $Q ≤ 10$.

310

$N ≤ 14,ドル $Q ≤ 10$.

428

$N ≤ 100,ドル $Q ≤ 10$.

510

$N ≤ 2,円 000,ドル $Q ≤ 10$.

619

$N ≤ 2,円 000$.

719

No additional constraints.

예제 입력 1

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

예제 출력 1

Yes
Yes
No

In the 1ドル$st scenario, the participant starts at position 0ドル,ドル finishes at position 100ドル,ドル and the time limit is 403ドル$ seconds. Rie can complete the race in 263ドル$ seconds, which is within the time limit, in the following way. Therefore, output Yes in the 1ドル$st line.

Order Action Time (sec.) Total Time (sec.)
1 Start at position 0ドル$ and move to position 30ドル$. 30ドル$ 30ドル$
2 Collect the 1ドル$st ball. 1ドル$ 31ドル$
3 Collect the 3ドル$rd ball. 1ドル$ 32ドル$
4 Move from position 30ドル$ to position 80ドル$. 150ドル$ 182ドル$
5 Collect the 2ドル$nd ball. 1ドル$ 183ドル$
6 Move from position 80ドル$ to position 100ドル,ドル and complete the race. 80ドル$ 263ドル$

In the 2ドル$nd scenario, the starting and finishing position is the same as the 1ドル$st scenario, but the time limit is 300ドル$ seconds. Rie can complete the race in 263ドル$ seconds, which is within the time limit, in the same way as above. Therefore, output Yes in the 2ドル$nd line.

In the 3ドル$rd scenario, the starting and finishing position is the same as the 1ドル$st and the 2ドル$nd scenarios, but the time limit is 262ドル$ seconds. There does not exist a way for Rie to complete the race within the time limit. Therefore, output No in the 3rd line.

This sample input satisfies the constraints of Subtasks 2, 3, 4, 5, 6, 7.

예제 입력 2

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

예제 출력 2

Yes
No
No

In the 1ドル$st scenario, the participant starts at position 0ドル,ドル finishes at position 0ドル,ドル and the time limit is 403ドル$ seconds. Rie can complete the race in 403ドル$ seconds, which is within the time limit, in the following way. Therefore, output Yes in the 1ドル$st line.

Order Action Time (sec.) Total Time (sec.)
1 Start at position 0ドル$ and move to position 30ドル$. 30ドル$ 30ドル$
2 Collect the 1ドル$st ball. 1ドル$ 31ドル$
3 Move from position 30ドル$ to position 80ドル$. 100ドル$ 131ドル$
4 Collect the 2ドル$nd ball. 1ドル$ 132ドル$
5 Move from position 80ドル$ to position 30ドル$. 150ドル$ 282ドル$
6 Collect the 3ドル$rd ball. 1ドル$ 283ドル$
7 Move from position 30ドル$ to position 0ドル,ドル and complete the race. 120ドル$ 403ドル$

In the 2ドル$nd and the 3ドル$rd scenarios, the starting and finishing position is the same as the 1ドル$st scenario, but the time limit is 300ドル$ seconds and 262ドル$ seconds, respectively. There does not exist a way for Rie to complete the race within the time limit, for both scenarios. Therefore, output No in the 2ドル$nd and the 3ドル$rd line.

This sample input satisfies the constraints of Subtasks 1, 2, 3, 4, 5, 6, 7.

예제 입력 3

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

예제 출력 3

No
Yes
No
Yes

This sample input satisfies the constraints of Subtasks 2, 3, 4, 5, 6, 7.

힌트

출처

Olympiad > Japanese Olympiad in Informatics > JOI 2023/2024 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /