1 solutions
-
0
C++ :
#include<iostream> #include<cstdio> #include<algorithm> #define Maxn 1000003 using namespace std; struct node{int x,y,v;} V[100010]={0}; int n,m,r; long long f[Maxn]={0}; bool cmp(const node a,const node b){ return a.y<b.y;} int main() { scanf("%d%d%d",&n,&m,&r); for(int i=1;i<=m;i++) scanf("%d%d%d",&V[i].x,&V[i].y,&V[i].v); sort(V+1,V+m+1,cmp); int j=1; f[0]=0; for(int i=1;i<=n;i++) { f[i]=f[i-1]; while(V[j].y==i) { f[i]=max(f[i],f[max(V[j].x-r-1,0)]+(long long)V[j].v); j++; } } cout<<f[n]<<endl; return 0; }
- 1
Information
- ID
- 763
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By