| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 37 | 16 | 13 | 44.828% |
Mr. JOI, who manages a famous ski resort on the IOI Plateau, has decided to commemorate the 15th anniversary of the ski resort’s opening by constructing a new ski resort on the adjacent KOI Plateau.
The KOI Plateau has $N$ points numbered from 1ドル$ to $N$. Currently, the altitude of point $i$ (1ドル ≤ i ≤ N$) is $H_i$m, and there exist no courses connecting each point on the plateau. Additionally, each point is equipped with one unused connection facility available.
The goal of Mr. JOI is to construct KOI Hotel at one of the $N$ points and then construct some courses connecting each point on the plateau so that one can ski down to the hotel from any point. Specifically, Mr. JOI will construct the ski resort according to the following steps:
The cost of constructing the ski resort is the sum of the costs of embankment works and extension works performed.
Write a program which, given information about each point on the KOI Plateau and the cost $K$ per operation of embankment work, finds the minimum cost of constructing the ski resort.
Read the following data from the standard input.
$N$ $K$
$H_1$ $C_1$
$H_2$ $C_2$
$\vdots$
$H_N$ $C_N$
Write one line to the standard output. The output should contain the minimum cost of constructing the ski resort.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 5 | $K ≥ 100,円 000,ドル $H_i ≤ 300,ドル $C_i ≤ 100$ (1ドル ≤ i ≤ N$). |
| 2 | 12 | $H_1 ≤ H_i,ドル $C_1 ≤ C_i,ドル $H_i ≤ 300$ (1ドル ≤ i ≤ N$). |
| 3 | 9 | $N ≤ 10,ドル $H_i ≤ 10$ (1ドル ≤ i ≤ N$). |
| 4 | 33 | $N ≤ 40,ドル $H_i ≤ 40$ (1ドル ≤ i ≤ N$). |
| 5 | 27 | $H_i ≤ 300$ (1ドル ≤ i ≤ N$). |
| 6 | 14 | No additional constraints. |
5 2 0 6 1 1 0 5 2 1 1 2
8
For example, the ski resort can be constructed in the following way:
Here, the cost of constructing the ski resort is 6ドル + 2 = 8$. Since it is impossible to construct the ski resort with a cost of 7ドル$ or less, output 8ドル$.
This sample input satisfies the constraints of Subtasks 3, 4, 5, 6.
5 100000 0 6 1 1 0 5 2 1 1 2
100010
This sample input differs from Sample Input 1 only in the value of $K$.
This sample input satisfies the constraints of Subtasks 1, 3, 4, 5, 6.
8 8 0 36 1 47 2 95 0 59 1 54 0 95 1 87 2 92
108
This sample input satisfies the constraints of Subtasks 2, 3, 4, 5, 6.