QOJ.ac

QOJ

时间限制: 1 s 内存限制: 2048 MB 总分: 100

#9711. K-矩形

统计

平面上有 $n$ 个点,坐标分别为 $(x_1, y_1), (x_2, y_2), \dots, (x_n, y_n)$,满足 $x_i < x_{i+1}$ 且 $0 < y_i$。

你需要放置若干个矩形来覆盖所有点,并满足以下限制:

(若点位于矩形内部或边界上,则视为被覆盖)

  1. 矩形的底边必须位于 $x$ 轴上。
  2. 每个矩形的代价为 $height \times (width + k)$(其中 $k$ 为输入给定的常数)。
  3. 任意两个不同的矩形不能有交集。
  4. 矩形可以退化为两条线段,即 $width = 0$。

请计算覆盖所有点的最小总代价。

输入格式

第一行包含两个整数 $n$ 和 $k$($1 \le n \le 4 \times 10^5, 1 \le k \le 10^6$),分别表示点的数量和题目描述中的系数。

接下来 $n$ 行,每行包含两个整数 $x_i$ 和 $y_i$($-10^6 \le x_i \le 10^6, 1 \le y_i \le 10^6$),表示第 $i$ 个点的坐标为 $(x_i, y_i)$。

输出格式

输出覆盖所有点的最小代价。

样例

样例输入 1

1 2
-666 666

样例输出 1

1332

样例输入 2

2 66666
-666 666
666 666

样例输出 2

45286668

Discussions

About Discussions

The discussion section is only for posting: 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.
  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.