QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 256 MB 満点: 100

#1803. 割草恶作剧

統計

Bessie 的表妹 Ella 和 Bella 来农场做客了。不幸的是,她们自打来到这里就一直在捣乱。

她们最新的计划是尽可能多地割草。农场的主要草地是一个巨大的 $T \times T$ 正方形。左下角坐标为 $(0,0)$,右上角坐标为 $(T,T)$。因此,该正方形包含 $(T+1)^2$ 个格点(坐标为整数的点)。

Ella 和 Bella 计划都从 $(0,0)$ 出发,以单位速度跑到 $(T, T)$,同时两人各持一根非常锋利且极具弹性的金属丝的一端。金属丝扫过的任何区域的草都会被割掉。Ella 和 Bella 可以选择不同的路径,但每条路径仅由向上和向右的步长组成,从一个格点移动到另一个格点。

Bessie 很担心割掉太多的草,于是她想出一个巧妙的计划来限制 Ella 和 Bella 的路径。草地上散布着 $N$ 朵美味的鲜花($1 \leq N \leq 2 \cdot 10^5$),每朵花都在不同的格点上。Bessie 将挑选一个鲜花集合 $S$,要求 Ella 和 Bella 都必须经过这些花(即 Ella 的路径必须经过 $S$ 中的所有花,Bella 的路径也必须如此)。为了给这些路径增加尽可能多的路点,Bessie 会在所有能被一只从 $(0,0)$ 到 $(T,T)$ 向上和向右移动的奶牛经过的鲜花子集中,选择最大的 $S$。

Ella 和 Bella 将在必须经过 $S$ 中鲜花的限制下,尝试最大化她们割掉的草的面积。请帮助 Bessie 选择 $S$,使得割掉的草的面积尽可能小。

输入格式

第一行包含 $N$ 和 $T$($1 \leq T \leq 10^6$)。接下来的 $N$ 行,每行包含一朵花的整数坐标 $(x_i, y_i)$。保证对于所有 $i$,都有 $1 \leq x_i, y_i \leq T-1$,且没有两朵花位于同一水平线或垂直线上。

在至少 20% 的测试用例中,进一步保证 $N \leq 3200$。

输出格式

输出一个整数,表示割掉的草的最小可能面积。

样例

输入格式 1

5 20
19 1
2 6
9 15
10 3
13 11

输出格式 1

117

说明

在上述示例中,Bessie 选择位于 $(10,3)$ 和 $(13,11)$ 的花是最优的。在这种情况下,最坏的情况下,Ella 和 Bella 将割掉三个矩形的草,总面积为 $117$。

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.