QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100

#21113. Stampede

الإحصائيات

Farmer John's $N$ cows $1 \leq N \leq 50,000$ appear to be stampeding along the road at the front of FJ's farm, but they are actually just running in a foot race to see which cow is the fastest.

Viewed from above, each cow is represented by a unit-length horizontal line segment, specified by the coordinates of its left corner point at time $t=0$. For example, $(-3,6)$ would specify a cow who at time $t=0$ is represented by the segment from $(-3,6)$ to $(-2,6)$. Each cow is moving to the right (in the $+x$ direction) at a certain rate, specified by the integer amount of time it takes her to move 1 unit to the right.

FJ is not particularly thrilled that his cows are outside running instead of in the barn producing milk. He plans to admonish them with a stern lecture after the race ends. In order to determine which of his cows are participating in the race, FJ situates himself at $(0,0)$ and looks along a ray extending in the $+y$ direction. As the race unfolds, FJ sees a cow if she is ever the first cow visible along this ray. That is, a cow might not be visible if another cow is "in front" of her during the entire time she crosses FJ's line of sight.

Please compute the number of cows FJ can see during the entire race.

Input

The first line of the input contains $N$. Each of the following $N$ lines describes a cow with three integers $x$ $y$ $r$, corresponding to a cow whose left endpoint is at $(x,y)$ at time $t=0$, moving to the right at a continuous speed of 1 unit of distance every $r$ units of time. The value of $x$ is in the range $-1000..-1$, the value of $y$ is in the range $1..1,000,000$ (and distinct for every cow, to prevent any possible collisions), and the value of $r$ is in the range $1..1,000,000$.

Output

A single integer, specifying the number of cows FJ can see during the entire race (from $t=0$ onward).

Examples

Input 1

3
-2 1 3
-3 2 3
-5 100 1

Output 1

2

FJ can see cows 1 and 2 but not cow 3.

Problem credits: Brian Dean

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.