| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 3 | 3 | 3 | 100.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:
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.
6 5 4 1 7 3 2 2 3 5 3 2 5 1 2 5 6
5 0 8 14
You can win the first level by spending 5ドル$ staracips by doing the following actions:
You can win the second level by spending 0ドル$ staracips by doing the following actions:
You can win the third level by spending 8ドル$ staracips by doing the following actions:
You can win the fourth level by spending 14ドル$ staracips by doing the following actions: