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

31734번 - Tower 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB1341086.452%

문제

The IOI Tower is an extremely tall tower equipped with a staircase for ascending. This staircase consists of 10ドル^{100}$ steps, numbered sequentially from the bottom as step 0ドル,ドル step 1ドル,ドル and so on. JOI-kun is currently on step 0ドル$ and intends to climb the staircase. JOI-kun can ascend the staircase by taking the following 2ドル$ types of actions. Descending the staircase is not permitted.

  • Ascend 1ドル$ step. This action takes $A$ seconds.
  • Jump from the current step to a step $D$ steps above, skipping the steps in between. This action takes $B$ seconds.

Currently, construction is ongoing at several locations on the staircase, and steps undergoing construction cannot be stepped on. Specifically, there are $N$ ongoing constructions, and the $i$-th construction (1ドル ≤ i ≤ N$) is being carried out at steps $L_i , L_{i+1}, \dots , R_i$.

The IOI Tower has $Q$ rooms numbered from 1ドル$ to $Q$. One can enter room $j$ (1ドル ≤ j ≤ Q$) from step $X_j$ of the staircase. Therefore, JOI-kun has decided to determine whether he can reach each room and, if possible, how many seconds it will take to reach there in the minimum time.

Given the information about JOI-kun, constructions, and rooms, create a program that determines whether JOI-kun can reach step $X_j$ for each $j$ (1ドル ≤ j ≤ Q$) and, if possible, calculates the minimum time it takes.

입력

Read the following data from the standard input.

$N$ $Q$

$D$ $A$ $B$

$L_1$ $R_1$

$L_2$ $R_2$

$\vdots$

$L_N$ $R_N$

$X_1$

$X_2$

$\vdots$

$X_Q$

출력

Output $Q$ lines to the standard output. On the $j$-th line (1ドル ≤ j ≤ Q$), output the minimum number of seconds it takes if JOI-kun can reach step $X_j$; otherwise, output -1.

제한

  • 1ドル ≤ N ≤ 200,円 000$.
  • 1ドル ≤ Q ≤ 200,円 000$.
  • 1ドル ≤ D ≤ 10^{12}$.
  • 1ドル ≤ A ≤ 1,円 000,円 000$.
  • 1ドル ≤ B ≤ 1,円 000,円 000$.
  • 1ドル ≤ L_i ≤ R_i ≤ 10^{12}$ (1ドル ≤ i ≤ N$).
  • $R_i + 1 < L_{i+1}$ (1ドル ≤ i ≤ N - 1$).
  • 1ドル ≤ X_j ≤ 10^{12}$ (1ドル ≤ j ≤ Q$).
  • Given values are all integers.

서브태스크

번호배점제한
15

$R_i ≤ 1,円 000,円 000$ (1ドル ≤ i ≤ N$), $X_j ≤ 1,円 000,円 000$ (1ドル ≤ j ≤ Q$).

238

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

325

$A = 1,ドル $B = D$.

432

No additional constraints.

예제 입력 1

3 1
4 10 35
4 5
10 12
14 14
13

예제 출력 1

120

JOI-kun can reach the 13ドル$th step of the staircase in 120ドル$ seconds following the steps below:

  1. Ascend from step 0ドル$ to step 1ドル$. This action takes 10ドル$ seconds.
  2. Ascend from step 1ドル$ to step 2ドル$. This action takes 10ドル$ seconds.
  3. Ascend from step 2ドル$ to step 3ドル$. This action takes 10ドル$ seconds.
  4. Jump from step 3ドル$ to step 7ドル,ドル skipping the steps in between. This action takes 35ドル$ seconds.
  5. Ascend from step 7ドル$ to step 8ドル$. This action takes 10ドル$ seconds.
  6. Ascend from step 8ドル$ to step 9ドル$. This action takes 10ドル$ seconds.
  7. Jump from step 9ドル$ to step 13ドル,ドル skipping the steps in between. This action takes 35ドル$ seconds.

Since it’s not possible to reach the 13ドル$th step of the staircase in less than 120ドル$ seconds, the output is 120ドル$.

This sample input satisfies the constraints of subtasks 1, 2, and 4.

예제 입력 2

5 10
10 1 9
7 11
25 32
37 38
43 44
50 52
6
12
18
24
30
36
42
48
54
60

예제 출력 2

6
11
17
22
-1
33
-1
44
-1
55

This sample input satisfies the constraints of subtasks 1, 2, and 4.

힌트

출처

Camp > JOI Spring Training Camp > JOI 2023/2024 Spring Training Camp 3-3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

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

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