QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 2048 MB 満点: 100

#1976. McFly

統計

一只名叫 McFly 的苍蝇今晚要去参加一个派对。不幸的是,这是一个人类的派对,而不是苍蝇的派对。

派对上有一张 $10^9$ 米长的桌子,人类会把饼干放在桌子上放一会儿,然后再拿走。这时,McFly 可以飞过来,在人类无人看管饼干时品尝饼干。品尝饼干是 McFly 最喜欢做的事情。他不想吃掉它们,他只是想尽可能多地品尝饼干。如果他品尝的饼干与他上一次品尝的饼干不同,或者这是他在派对上品尝的第一块饼干,他就会感到满足。这意味着他可以多次品尝同一块饼干,只要他在两次品尝同一块饼干之间至少品尝过另一块饼干即可。

但 McFly 早有准备。他去见了一位算命先生,想知道派对上会发生什么。算命先生告诉他有 $n$ 块饼干会被放在桌子上。第 $i$ 块饼干将在位置 $x_i$(即距离桌子起点 $x_i$ 米处),从时间 $s_i$ 到 $f_i$(时间以秒为单位,从派对开始算起)。保证在同一时间,没有两块饼干处于同一位置;即对于每一对 $i \neq j$ 且 $x_i = x_j$ 的情况,都有 $f_i \leqslant s_j$ 或 $f_j \leqslant s_i$。更具体地说,桌子可以看作一条水平线,McFly 和饼干都被视为线上的点。McFly 可以在派对开始前的任何时间出现在任何位置。在此之后的任何时间,他都可以以每秒 1 米的速度沿桌子飞行,或者保持原地不动。如果 McFly 在时间 $t$(其中 $s_i \leqslant t < f_i$)位于位置 $x_i$,他就可以品尝第 $i$ 块饼干。品尝饼干不需要时间。

请帮助 McFly 尽可能多地享受品尝饼干的乐趣。

输入格式

第一行包含一个整数 $n$ ($1 \leqslant n \leqslant 100\,000$)。接下来的 $n$ 行中,第 $i$ 行包含三个整数 $x_i, s_i$ 和 $f_i$ ($0 \leqslant x_i \leqslant 10^9, 0 \leqslant s_i < f_i \leqslant 10^9$)。饼干在桌子上的总时间最多为 $10^5$ ($\sum_{i=1}^{n} f_i - s_i \leqslant 10^5$)。

输出格式

输出 McFly 可以享受的最大品尝次数。

样例

输入 1

4
7 2 5
1 2 4
4 1 6
2 9 10

输出 1

3

输入 2

3
0 0 11
2 0 11
3 4 9

输出 2

8

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.