QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100
الإحصائيات

There are $n$ points on the plane, ($x_1, y_1$),($x_2,y_2$)…($x_n,y_n$), $x_i< x_{i+1}$,$0< y_i$

You need to place several rectangles to cover all of them with the following constraints.

(a point is covered if it lies inside the rectangle or on the side of the rectangle)

  1. The bottom side of the rectangle should be $x$-axis
  2. The cost of a rectangle is $height\times(width + k)$ ($k$ is given by input)
  3. Any two different rectangles can't have an intersection
  4. the rectangle can degenerate to two lines, which means $width = 0$

Please calculate the minimum cost to cover all of the points.

Input

The first line contains two integers,

$n$ and $k$ ($1 \le n \le4\times10^5, 1\le k \le 10^6$) ---

the number of points and the coefficient described in the problem.

Each of the next $m$ lines contains two integers,

$x_i$ and $y_i$($-10^6 \le x_i \le 10^6, 1\le y_i \le 10^6$)--- meaning $i^{th}$ point is at ($x_i$ , $y_i$).

Output

Output the minimum cost to cover all of the points.

Sample Input 1

1 2
-666 666

Sample Output 1

1332

Sample Input 2

2 66666
-666 666
666 666

Sample Output 2

45286668

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.