Blaster the Daredevil

시간 제한7초메모리 제한2048 MB

요약
원점에서 출발하는 직선이 최대한 많은 수직 선분과 만나도록 발사 각도를 정해 통과하는 hoop 수의 최댓값을 구한다.
난이도

어려움10점 중 8점

유형
기하, 정렬, 그리디, 이분 탐색
정답자
아직 제출이 없습니다

문제

This year, Blaster wants to make a grand exit from graduation, and what better way to do so than by launching himself out of a cannon? Blaster's stunt can be modeled as a path in the XY-plane where the cannon is positioned at the origin, (0,0)(0, 0), and can be aimed at any angle.

Suspended in the air are nn floating hoops, each represented as a vertical segment. The ii-th hoop is located x_ix\_i meters along the X-axis. The bottom of the hoop is positioned a_ia\_i meters above the X-axis, and the top of the hoop is positioned b_ib\_i meters above the X-axis.

Blaster, modeled as a single point, will follow a perfectly straight-line trajectory after launch (since he has conveniently disabled Earth's gravity for this stunt). He is considered to pass through a hoop if his trajectory intersects or touches at least one point on the vertical line segment between (x_i,a_i)(x\_i, a\_i) and (x_i,b_i)(x\_i, b\_i).

Your task is to determine the maximum number of hoops Blaster can pass through if you carefully choose the cannon's launch angle.

입력

The first line contains a single integer nn (1≤n≤105)(1 \leq n \leq 10^5) — the number of hoops.

Each of the next nn lines contains three integers x_i,a_i,b_ix\_i, a\_i, b\_i (1≤x_i≤109,0≤a_i≤b_i≤109)(1 \leq x\_i \leq 10^9, 0 \leq a\_i \leq b\_i \leq 10^9), describing the position and height range of the ii-th hoop.

It is guaranteed that perturbing the endpoints of hoops up or down by at most 10−610^{-6} meters will not affect the answer.

출력

Print a single integer---the maximum number of hoops Blaster can pass through for an optimal choice of launch angle.

예제1

  1. 예제 1

    입력
    5
    2 1 3
    4 2 5
    3 1 4
    5 3 6
    1 2 3
    
    예상 출력
    4