QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100

#15775. Archery

统计

Momo is playing a 2D archery game. As shown in Figure 1, the x-axis represents the ground, and there are several vertical line segments in the first quadrant acting as targets. No two targets share any common points, and no target touches the coordinate axes.

Momo controls an archer located at $(0, 0)$. She can shoot a light arrow with piercing capabilities at any angle between $0^\circ$ and $90^\circ$ (exclusive of $0^\circ$ and $90^\circ$) with any amount of force. Since there is no air resistance in the game and the light arrow has no thickness, the trajectory of the arrow is a standard parabola. Any target that the trajectory passes through is considered hit, including those where only an endpoint is hit.

There are multiple modes in this game, and Momo's favorite is the level-clearing mode. In this mode, there is only one target in the first level. Hitting this target allows entry into the second level, where a new target appears in addition to the one from the first level. If she can hit both targets with a single arrow, she enters the third level, where a third target appears. This continues, with a new target appearing after each level. To enter level $K+1$, she must hit all $K$ targets that have appeared up to level $K$ with a single arrow; otherwise, the game ends.

Momo has spent a lot of time on this game but can only reach the seventh level, "Seven Stars in a Row," which puzzles her. She has managed to obtain the positions of the targets that appear in each level and wants you to tell her the maximum number of levels she can pass.

Input

The first line contains a positive integer $N$, representing the total number of levels. The next $N$ lines each contain three space-separated positive integers $x_i$, $y_{i1}$, and $y_{i2}$ ($y_{i1} < y_{i2}$), representing that the target appearing in level $i$ has an x-coordinate of $x_i$ and a y-coordinate range from $y_{i1}$ to $y_{i2}$.

It is guaranteed that 30% of the data satisfies $N \le 100$, 50% of the data satisfies $N \le 5000$, and 100% of the data satisfies $N \le 100000$. All given coordinates do not exceed $10^9$.

Output

Output a single integer representing the maximum number of levels passed.

Examples

Input 1

5
2 8 12
5 4 5
3 8 10
6 2 3
1 3 7

Output 1

3

Note

As shown in Figure 1, it is possible to hit the targets of the first three levels.

Figure 1

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.