• + 1 comment

    I would not suggest eclipsing list

    • + 2 comments

      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;
      

      }

      • + 1 comment

        Maximum array size has to be 10^7 which is not possible in case of C. I tried Dynamic memory allocation (malloc) which worked but got TLE for bigger test cases

        • + 0 comments

          yeah it is getting a tle. We need to use a different algorithm. I wanted to know what the problem in my code was so i posted my solution.

      • + 0 comments

        use long instead of int.