#P8021. [ONTAK2015] Bajtman i Okrągły Robin

[ONTAK2015] Bajtman i Okrągły Robin

Problem Description

There are nn robbers. The ii-th robber will choose one time slot of length 11 to rob from the following intervals: $[a_i, a_i + 1], [a_i + 1, a_i + 2], \cdots, [b_i - 1, b_i]$, and plans to steal cic_i dollars. As a security guard, in each time slot of length 11 you can stop at most one robber. What is the maximum loss you can recover?

Input Format

The first line contains an integer nn.

The next nn lines each contain three integers ai,bi,cia_i, b_i, c_i.

Output Format

One line containing an integer, representing the required value.

4
1 4 40
2 4 10
2 3 30
1 3 20
90

Hint

For 100%100\% of the testdata, 1n5×1031 \leq n \leq 5 \times 10^3, 1ai<bi5×1031 \leq a_i < b_i \leq 5 \times 10^3, 1ci1041 \leq c_i \leq 10^4.

Translated by ChatGPT 5