-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3027.cpp
More file actions
52 lines (44 loc) · 1.01 KB
/
3027.cpp
File metadata and controls
52 lines (44 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*************************************************************************
> File Name: 3027.cpp
> Author: dulun
> Mail: [email protected]
> Created Time: 2016年03月06日 星期日 15时46分36秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define LL long long
using namespace std;
const int N = 50086;
struct Line
{
int a, b, c;
};
Line l[1008];
int dp[1008];
int cmp(Line a, Line b){ return a.b < b.b; }
int main()
{
int n;
cin>>n;
int ans = 0;
for(int i = 1; i <= n; i++)
{
cin>>l[i].a>>l[i].b>>l[i].c;
}
sort(l+1, l+1+n, cmp);
for(int i = 1; i <=n; i++) dp[i] = l[i].c;
for(int i = 2; i <= n; i++)
{
for(int j = 1; j < i; j++)
{
if(l[j].b <= l[i].a)
dp[i] = max(dp[i], dp[j] + l[i].c);
}
}
for(int i = 1; i <= n; i++) ans = max(ans, dp[i]);
cout<<ans<<endl;
return 0;
}