We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Why is my code not working on the same approach ?
Please help Can't find anything wrong !
include
include
using namespace std;
int main(){
int N,M,a,b,c;
cin>>N>>M;
long int *arr=new long int[N+1];
for(int i=0;i<M;i++){
cin>>a>>b>>c;
arr[a]+=c;
if(b+1<=N){
arr[b+1]-=c;
}
}
int x=0,ans=0;
for(int i=1;i<=N;i++){
x+=arr[i];
ans=max(ans,x);
}
cout<<ans;
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
Why is my code not working on the same approach ? Please help Can't find anything wrong !
include
include
using namespace std;
int main(){
return 0; }