Created
November 15, 2018 18:46
-
-
Save gabrielepalma/de8caf951f67beacb18fe5917da8de61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
long int N,K,p,q,sum,i,j,max=0,x=0; | |
cin>>N>>K; | |
long int *a=new long int[N+1](); | |
for(i=0;i<K;i++) | |
{ | |
cin>>p>>q>>sum; | |
a[p]+=sum; | |
if((q+1)<=N) a[q+1]-=sum; | |
} | |
for(i=1;i<=N;i++) | |
{ | |
x=x+a[i]; | |
if(max<x) max=x; | |
} | |
cout<<max; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment