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.
Can some one please help as to why my solution gives a segmentation fault?
include
include
include
include
int main() {
unsigned long long int n,m,l,b,k,i,val=0;
scanf("%llu%llu",&n,&m);
unsigned long long int a[n+1];
for(i=1;i<=n;i++)
{
a[i]=0;
}
while(m--)
{
scanf("%llu%llu%llu",&l,&b,&k);
for(i=l;i<=b;i++)
{
a[i]+=k;
if(a[i]>val)
{
val=a[i];
}
}
}
printf("%llu",val);
return 0;
}
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 →
Can some one please help as to why my solution gives a segmentation fault?
include
include
include
include
int main() {
}