favorite We need a little bit of your help to keep things running, click on this banner to learn more

2018 Цикл Интернет-олимпиад для школьников

Shooting section

After Atreus's successful training in "Claw" archery, Fei decided not to stop there and open a whole archery section.

n students came to the section. Fay numbered them with integers from 1 to n. At the beginning of the lesson, the students stood along the coordinate line drawn in advance on the floor, with the i - th student standing at the point with the coordinate xi. It turned out that the coordinates of the students strictly increased, that is, xi < xi+1 for all i from 1 to n - 1.

Each of the students has his own magic bow, which is characterised by its range of ri and the power of ci. Both parameters are positive integers. When a student makes a shot from a bow, a magic projectile begins to fly along the coordinate line in the direction of increasing coordinate. The projectile flies as long as its strength is positive. At the time of the shot, the charge force equals to the strength of the bow from which the shot is fired. Each time a projectile flies next ri units of distance along a straight line, it loses one unit of force.

If the student fired, and the projectile fired by him reached the next in order along the straight student, the projectile ceases to fly, and the student who reached the projectile suddenly decides that he also needs to fire a shot and fires it. The student will fire a shot even if the projectile reaches it with a power of 0.

Faye wants every student to fire at least one shot. To do this, she can command some students to do this, after which these students will fire a shot, which may entail new shots of other students.

Help Faye to determine the minimum number of students who need to be instructed to fire a shot so that each student fires at least one shot as a result.


First line contains number of students n (1n1000) at the Fei's section.

Each of the next n lines contains three integers xi, ri and ci (1xi109, 1ri, ci100) - the coordinate of the next student, as well as the range and strength of his bow, respectively. It is guaranteed that xi < xi+1 for all i from 1 to n - 1.


Print the minimum number of students who need to be given the command to fire a shot so that each student as a result fires at least one shot.

Time limit 1 second
Memory limit 128 MiB
Input example #1
1 3 3
5 1 2
8 2 3
10 1 2
11 3 2
Output example #1
Source 2018 Cycle of Internet Olympiads for schoolchildren, second team season olympiad, Basic nomination, October 20, Problem E