Apprentice Learning Trajectory

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

Abigail is an apprentice studying to become a blacksmith. She wants to plan her learning trajectory and make as many swords as possible on her way to becoming a famous expert.

There are nn masters willing to host her as their apprentice. The ii-th master will start working at the minute a_ia\_i and end working at the minute b_ib\_i, working for a total of b_ia_ib\_i - a\_i minutes. During this interval of time, Abigail can work at this master's forge. She can enter and leave the forge several times and produce one or several swords upon each arrival. However, in order to produce a sword under supervision of the ii-th master she has to work there for t_it\_i minutes in a row. She can't leave the sword unfinished and continue working on it upon her next arrival to this forge.

Help Abigail make an optimal plan and calculate the maximum number of swords she can produce under the supervision of nn masters.

입력

The first line contains integer nn (1n200,0001 \le n \le 200\\,000) --- the number of masters.

Each of the next nn lines contains three integers a_i,b_i,t_ia\_i, b\_i, t\_i (1a_i<a_i+t_ib_i10181 \le a\_i < a\_i + t\_i \le b\_i \le 10^{18}) --- the start and the end time of master's work, and the time needed to make one sword in their forge.

출력

Output the maximum number of swords Abigail can produce using the optimal learning trajectory.