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

31728번 - Ski 2 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB37161344.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:

  1. Perform the following embankment work any number of times (possibly zero):
    • Choose a point $i,ドル and increase the altitude of point $i$ by 1ドル$m. The cost of this work is $K$ per operation.
  2. Choose a point from the $N$ points and construct KOI Hotel there.
  3. Perform the following extension work any number of times (possibly zero):
    • Choose a point $i,ドル and build one connection facility at point $i$. The cost of this work is $C_i$ per operation.
  4. For each of the remaining $N - 1$ points excluding the point with KOI Hotel, perform the following construction:
    • Let $i$ be the number of the point. Select another point $j$ with a strictly lower altitude than point $i,ドル and use one unused connection facility at point $j$ to construct a one-way course from point $i$ to point $j$. Note that if there is no point with an unused connection facility and a strictly lower altitude than point $i,ドル the goal cannot be achieved.

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ドル ≤ N ≤ 300$.
  • 1ドル ≤ K ≤ 10^9$
  • 0ドル ≤ H_i ≤ 10^9$ (1ドル ≤ i ≤ N$).
  • 1ドル ≤ C_i ≤ 10^9$ (1ドル ≤ i ≤ N$).
  • Given values are all integers.

서브태스크

번호배점제한
15

$K ≥ 100,円 000,ドル $H_i ≤ 300,ドル $C_i ≤ 100$ (1ドル ≤ i ≤ N$).

212

$H_1 ≤ H_i,ドル $C_1 ≤ C_i,ドル $H_i ≤ 300$ (1ドル ≤ i ≤ N$).

39

$N ≤ 10,ドル $H_i ≤ 10$ (1ドル ≤ i ≤ N$).

433

$N ≤ 40,ドル $H_i ≤ 40$ (1ドル ≤ i ≤ N$).

527

$H_i ≤ 300$ (1ドル ≤ i ≤ N$).

614

No additional constraints.

예제 입력 1

5 2
0 6
1 1
0 5
2 1
1 2

예제 출력 1

8

For example, the ski resort can be constructed in the following way:

  1. Perform embankment work twice at point 1ドル$ and once at point 5ドル$. The total cost of these embankment works is 2ドル \times (2 + 1) = 6$. As a result, the altitude of each point becomes 2ドル,ドル 1ドル,ドル 0ドル,ドル 2ドル,ドル 2ドル$ m starting from point 1ドル$.
  2. Construct KOI Hotel at point 3ドル$.
  3. Perform extension work twice at point 2ドル$. The total cost of these extension works is 1ドル \times 2 = 2$. As a result, the number of connection facilities at each point becomes 1ドル,ドル 3ドル,ドル 1ドル,ドル 1ドル,ドル 1ドル$ starting from point 1ドル$.
  4. Construct 4ドル$ courses: one from point 1ドル$ to point 2ドル,ドル one from point 2ドル$ to point 3ドル,ドル one from point 4ドル$ to point 2ドル,ドル and one from point 5ドル$ to point 2ドル$.

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.

예제 입력 2

5 100000
0 6
1 1
0 5
2 1
1 2

예제 출력 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.

예제 입력 3

8 8
0 36
1 47
2 95
0 59
1 54
0 95
1 87
2 92

예제 출력 3

108

This sample input satisfies the constraints of Subtasks 2, 3, 4, 5, 6.

힌트

첨부

출처

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

채점 및 기타 정보

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

출처

대학교 대회

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

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