#000054

z-menadzer

Mr. Little Z has decided to find a job as a manager. After a few days of looking for a job, he has finally found a job at the famous company Zoogle. At his first day of work he got a serious assignment:


The head manager of the company loves to watch movies. However, he doesn't have enough free time. Mr. Little Z's assignment is to record movies for the head manager. The head manager has given Mr. Little Z a list of movies and for each movie: when it starts, when it ends, and how much money Mr. Little Z will get if he records the movie.


Mr. Little Z has only one recorder and he wants to record the movies so that he can earn as much money as possible.


InputThe first line of the standard input contains a natural number N (1<=N<=100000) representing the number of movies on the list. In the next N lines you are given three natural numbers. P, K and O, where 1<=P < K <= 2000000000, and 1<=O<=1000. P represents the time when the movie starts, k represents the time when the movie ends, and O represents Mr. Little Z's earnings for the movie if it is recorded.

OutputTo the standard output write only one number corresponding to Mr. Little Z's maximum earnings.

Input:
3
1 5 2
2 6 3
6 8 2

Output:
4
Additional example:

Input:
4
1 3 2
4 6 2
2 5 8
4 5 3

Output:
8

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.