Why is it throwing a runtime error(SIGCONT)? Problem: COPS

#include <stdio.h>

int main(void) {
int r,t,m,x,y,i,j,c[100];
int h[100];

scanf("%d", &t);
while(t--)
{
 scanf("%d %d %d", &m, &x, &y);
 
  for(i=1; i<=m; i++)
  scanf("%d", &c[i]);
  
  
 r=0;
  for(i=0; i<100; i++)
  h[i]=0; 
  
  for(i=1;i<=m; i++)
  {
  	
  
  	if((c[i]- x*y)<0)
  	{
  		for(j=0; j<(c[i]+ x*y); j++)
  		h[j]++;
	  }
	  if((c[i]- x*y)>=0)
  	{
  		for(j=(c[i]- x*y)-1; j<(c[i]+ x*y); j++)
  		h[j]++;
	  }
	  
	  
  }
  
  for(i=0; i<100; i++)
  {
  	if(h[i]==0)
  	r++;
  }
  
  printf("%d\n", r);
}
return 0;

}

I made a modification to your code here. I increased the size of your h[] array to 1000. Now, it passes.

I think at some point in your j loops, you are trying to access array positions which go beyond the array size and is causing the RTE.

Feel free to ask if you have any more doubts. Hope this helped :slight_smile:

//