title: Segmentation Fault while using long long int
body: <p>I was solving <a href="https://www.hackerrank.com/challenges/crush/problem" rel="nofollow noreferrer">this</a> question. I wrote the code and received wrong answer for 10 test cases and correct for 6. I checked the constraints and since they are beyond the range of <em>int</em> therefore I replaced <em>int</em> by <em>long long int</em>. 9 test cases passed but the other 7 are showing segmentation fault now.</p>
  
  <p>What can be the reason for this?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      long long int n,m; 
      cin&gt;&gt;n&gt;&gt;m; 
      long long int arr[n]={0}; 
      long long int a,b,k; 
      long long int maxi=0;
  
      while(m--)
      {
          cin&gt;&gt;a&gt;&gt;b&gt;&gt;k;
  
          for(long long int i=a-1; i&lt;b; i++)
          {
              arr[i]+=k;
          }
      }
  
      for(long long int i=0; i&lt;n; i++)
      {
          if(maxi&lt;arr[i]){maxi=arr[i];}
      }
  
      cout&lt;&lt;maxi;
  
      return 0;
  }
  </code></pre>