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.
I have similar solution but it is giving timeout for some cases. why is it so? :
include
using namespace std;
int main()
{
long int n,m;
cin>>n>>m;
long int arr[n] = {0};
for(long int i = 0;i>a>>b>>k;
arr[a-1]+=k;
if(b<=n)
arr[b]-=k;
}
long int max = 0;
long int s=0;
for(long int i=0;imax)
max = s;
}
cout<
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
I have similar solution but it is giving timeout for some cases. why is it so? :
include
using namespace std;
int main() { long int n,m; cin>>n>>m; long int arr[n] = {0}; for(long int i = 0;i>a>>b>>k; arr[a-1]+=k; if(b<=n) arr[b]-=k; } long int max = 0; long int s=0; for(long int i=0;imax) max = s; } cout<