QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100

#9711. K-rectangle

Statistics

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
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.