-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathProjects(CSES).cpp
More file actions
38 lines (36 loc) · 920 Bytes
/
Projects(CSES).cpp
File metadata and controls
38 lines (36 loc) · 920 Bytes
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
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define ll long long int
#define PI pair<pair<int,int>,int>
#define VPI vector<PI>
#define a(PI) PI.first.first
#define b(PI) PI.first.second
#define r(PI) PI.second
int main()
{
ll n,day_num=-1;
cin >> n;
VPI PR;
map<ll,ll> day;
for(ll i=0;i<n;i++)
{
ll x,y,z;
cin >> x >> y >> z;
PR.push_back({{x,y+1},z});
day[x];
day[y+1];
}
for(auto it=day.begin();it!=day.end();it++) (*it).second = ++day_num;
vector<vector<pair<ll,ll>>> completed(day_num+1);
for(int i=0;i<n;i++) completed[day[b(PR[i])]].emplace_back( day[a(PR[i])],r(PR[i]) );
ll dp[day_num+1]={0};
for(ll i=0;i<=day_num;i++)
{
if(i) dp[i]=dp[i-1];
for(auto it:completed[i]) dp[i]=max(dp[i],it.second+dp[it.first]);
}
cout << dp[day_num] << endl;
return 0;
}