| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1.5 초 | 1024 MB | 145 | 39 | 34 | 26.772% |
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:
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 | 7 | $N ≤ 7$, $Q ≤ 10$, $S_j = 0$, $G_j = 0$ ($1 ≤ j ≤ Q$). |
| 2 | 7 | $N ≤ 7$, $Q ≤ 10$. |
| 3 | 10 | $N ≤ 14$, $Q ≤ 10$. |
| 4 | 28 | $N ≤ 100$, $Q ≤ 10$. |
| 5 | 10 | $N ≤ 2\, 000$, $Q ≤ 10$. |
| 6 | 19 | $N ≤ 2\, 000$. |
| 7 | 19 | No additional constraints. |
3 100 30 80 30 3 0 100 403 0 100 300 0 100 262
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.
3 100 30 80 30 3 0 0 403 0 0 300 0 0 262
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.
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
This sample input satisfies the constraints of Subtasks 2, 3, 4, 5, 6, 7.