title: HackerEarth challenge Program - Help Captain Gordon - which corner case am I missing?
body: <p>This is a HackerEarth programming challenge question. Here's <a href="http://www.hackerearth.com/mindsweeper_2/algorithm/help-captain-gordon/" rel="nofollow">link</a></p>
  
  <p>Here's the problem</p>
  
  <blockquote>
    <p>A large network of criminals is working under JOKER to destroy and
    demolish Gotham city. Captain Gordon is quite tensed about what these
    criminals can do to Gotham city. Fortunately, Batman comes to his
    rescue and with the help of the Batman, he was able to rescue N
    hostages that were trapped by the criminals working under JOKER. He
    makes them stand in a line and each of the N hostage is given id
    between 1 to N (inclusive) and no 2 hostages have same id. You are a
    newly hired programmer who is assigned the task of keeping track of
    the health status of hostages as Captain Gordon heals them by giving
    them aspirin each time. Initially,health of each hostage is 0. He then
    performs following action -</p>
    
    <p>• Gives Aspirin of value v to hostages
    having id between x and y (both inclusive) which increaces their
    present health by v.</p>
    
    <p>• He asks you to give him the sum of the health
    of all the hostages having id between x and y (both inclusive) Can you
    write a program which keeps track of Gordon’s action?</p>
    
    <p>INPUT 1st Line contains N-no. of hostages 2nd line contains M-no. of
    actions performed by Captain Gordon. The next M lines contain the
    actions in the form of either “ 1 x y v “ which denotes Action 1 or “
    2 x y “ which denotes Action 2.</p>
    
    <p>OUTPUT For each action that Captain Gordon does, if Action 1 is
    carried out, output nothing but if Action 2 is carried out, the
    program must output the result that Gordon asks for.</p>
    
    <p>CONSTRAINTS</p>
    
    <p>1) N&lt;=10^5</p>
    
    <p>2) M&lt;=10^5</p>
    
    <p>3) 1&lt;=x &lt; y&lt;=N</p>
    
    <p>4) 0&lt;=v&lt;=100</p>
  </blockquote>
  
  <pre><code>Sample Input
  5
  6
  2 1 5
  1 3 4 5
  2 2 4
  1 1 3 10
  1 1 5 5
  2 1 5
  
  Sample Output
  0
  10
  65
  </code></pre>
  
  <p>There is a sample input and sample output. Before submitting the answer you can compile your code and test over there. my code passed it. Then you can submit your answer. After submitting the answer your code is tested for various test cases.</p>
  
  <p>Out of the 10 tests, my code passed 6 tests successfully and 4 partially. And the problem is you can't see which tests are there!!</p>
  
  <p>Can someone finds whats wrong with my code or which corner cases I am missing. Here's the code</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
  
      int N, M, i, j, x, y, v, sum, actn, arr[100001] = {0};
  
      scanf("%d%d", &amp;N, &amp;M);
  
      for (i = 1; i &lt;= M; i++) {
          scanf("%d", &amp;actn);
  
          if (actn == 1) {
              scanf("%d%d%d", &amp;x, &amp;y, &amp;v);
              for (j = x; j &lt;= y; j++)
                  arr[j] += v;
          } else {
              scanf("%d%d", &amp;x, &amp;y);
              sum = 0;
              for (j = x; j &lt;= y; j++)
                  sum += arr[j];
              printf("%d\n", sum);
          }
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Thanks in advance</p>