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

34607번 - Hold the Star 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB333100.000%

문제

You are playing a computer game with $n$ rooms, $m$ characters, and one star. The rooms are arranged from left to right and numbered from 1ドル$ to $n$ in that order. The characters are numbered from 1ドル$ to $m$. At any time, each character is in one of the rooms and the star is either in one of the rooms or held by one of the characters. The objective of the game is for the star to be held by character $m$.

You can play the game by performing several actions. Each action costs a certain amount of staracips (the unit of currency in the game), possibly zero. In each action, you choose a character $x$ (let room $y$ be the room the character is currently in) and command the character to do either of the following:

  • Move to one of the adjacent rooms ($y − 1$ or $y + 1$), if such a room exists. If character $x$ is holding the star, then the character continues to hold the star. This action costs $s_x$ staracips. The values of $s_1, s_2, \dots , s_m$ are given.
  • Pick the star up and hold it, if the star is currently in room $y$ and is not held by any character. This action costs 0ドル$ staracips.
  • Put the star down and release it, if the star is currently held by character $x$. The star then falls to room $y$. This action costs 0ドル$ staracips.

The game contains $q$ levels, numbered from 1ドル$ to $q$. In all levels, each character $i$ is initially in room $r_i$ and character $m$ must hold the star to win the level. The only difference between the levels is that, in each level $j,ドル the star is initially in room $l_j$.

For each level, you want to compute the minimum total staracips you have to spend to win the level. Note that you don’t have to minimize the number of actions.

입력

The first line of input contains three integers $n,ドル $m,ドル and $q$ (1ドル ≤ n ≤ 10^9$; 1ドル ≤ m ≤ 100,円 000$; 1ドル ≤ q ≤ 100,円 000$). The $i$-th of the next $m$ lines contains two integers $r_i$ and $s_i$ (1ドル ≤ r_i ≤ n$; 1ドル ≤ s_i ≤ 10^9$). The $j$-th of the next $q$ lines contains an integer $l_j$ (1ドル ≤ l_j ≤ n$).

출력

For each level in order, output the minimum total staracips you have to spend to win the level.

제한

예제 입력 1

6 5 4
1 7
3 2
2 3
5 3
2 5
1
2
5
6

예제 출력 1

5
0
8
14

You can win the first level by spending 5ドル$ staracips by doing the following actions:

  1. Character 5ドル$ moves from room 2ドル$ to room 1ドル$. This action costs 5ドル$ staracips.
  2. Character 5ドル$ picks the star up.

You can win the second level by spending 0ドル$ staracips by doing the following actions:

  1. Character 5ドル$ picks the star up.

You can win the third level by spending 8ドル$ staracips by doing the following actions:

  1. Character 4ドル$ picks the star up.
  2. Character 4ドル$ moves from room 5ドル$ to room 4ドル$. This action costs 3ドル$ staracips.
  3. Character 4ドル$ moves from room 4ドル$ to room 3ドル$. This action costs 3ドル$ staracips.
  4. Character 4ドル$ puts the star down.
  5. Character 2ドル$ picks the star up.
  6. Character 2ドル$ moves from room 3ドル$ to room 2ドル$. This action costs 2ドル$ staracips.
  7. Character 2ドル$ puts the star down.
  8. Character 5ドル$ picks the star up.

You can win the fourth level by spending 14ドル$ staracips by doing the following actions:

  1. Character 2ドル$ moves from room 3ドル$ to room 4ドル,ドル then to room 5ドル,ドル then to room 6ドル$. These actions cost 3ドル \times 2 = 6$ staracips in total.
  2. Character 2ドル$ picks the star up.
  3. Character 2ドル$ moves from room 6ドル$ to room 5ドル,ドル then to room 4ドル,ドル then to room 3ドル,ドル then to room 2ドル$. These actions cost 4ドル \times 2 = 8$ staracips in total.
  4. Character 2ドル$ puts the star down.
  5. Character 5ドル$ picks the star up.

노트

출처

ICPC > Regionals > Asia Pacific > Asia Pacific Championship > The 2025 ICPC Asia Pacific Championship F번

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

출처

대학교 대회

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

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