#d2461. 任务分配

任务分配

Task Assignment

Problem Description

You have nn tasks. The ii-th task starts at time sis_i and ends at time eie_i; if you do it, you get a profit of wiw_i.

But you can do at most one task at any moment. Choose which tasks to do so that your total profit is maximized.

Note that it is allowed to start the next task immediately after the previous one ends.

Input Format

The first line contains an integer nn.

The next nn lines each contain three integers si,ei,wis_i, e_i, w_i.

Output Format

Output one number: the answer.

Sample Input

3
1 3 100
2 4 199
3 5 100

Sample Output

200

Constraints

For all data, 1≤n≤1031 \le n \le 10^3, 1≤si<ei≤1031 \le s_i < e_i \le 10^3, and 1≤wi≤1051 \le w_i \le 10^5.