6744.Projects

Time Limit: 1s Memory Limit: 512MB

There are $n$ projects you can attend. For each project, you know its starting and ending days and the amount of money you would get as reward. You can only attend one project during a day.

What is the maximum amount of money you can earn?

Input Format(From the terminal/stdin)

The first input line contains an integer $n$ : the number of projects.

After this, there are $n$ lines. Each such line has three integers $a_i$ , $b_i$ , and $p_i$ : the starting day, the ending day, and the reward.

  • $1 \le n \le 2 \cdot 10^5$
  • $1 \le a_i \le b_i \le 10^9$
  • $1 \le p_i \le 10^9$

Output Format(To the terminal/stdout)

Print one integer: the maximum amount of money you can earn.

Sample Input

Copy
4
2 4 4
3 6 6
6 8 2
5 7 3
 \n
 · · \n
 · · \n
 · · \n
 · · \n

Sample Output

Copy
7
 \n
Source: CSES, Dynamic Programming, 1140

Submit

请先 登录

© 2025 FAQs