logo AlgoBeat OnlineJudge
登录 注册

#213029. [NERC 2019] Apprentice Learning Trajectory

内存限制:512 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 masters willing to host her as their apprentice. The -th master will start working at the minute and end working at the minute , working for a total of 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 -th master she has to work there for 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 masters.

输入格式

The first line contains integer () --- the number of masters.

Each of the next lines contains three integers () --- 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.

样例

样例输入 1

2
5 7 1
1 9 2

样例输出 1

5

样例输入 2

3
1 10 4
6 12 3
9 13 2

样例输出 2

4

样例输入 3

3
1 13 4
6 11 2
9 13 3

样例输出 3

4

数据范围与提示