I was trying to solve a problem( https://www.codechef.com/LOCMAY17/problems/LOC172) on an online judge. Following is the code for the problem.When i submit the judge gives runtime error(). All the variables have been used acc to constraints.Please help me in finding out what is going wrong? the code is given below:
#include<iostream>
#include<stdlib.h>
using namespace std;
main()
{
long long int h,w;
while(1)
{
    cin>>h>>w;
    if(h==-1 && w==-1)
        exit(1);
    int n,i,j;
    cin>>n;
    long long int arr[n][4];
    for(i=1;i<=n;i++)
    {
        cin>>arr[i][1]>>arr[i][2]>>arr[i][3];
        arr[i][4]=0;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if((llabs(arr[j][2]-arr[i][2]))<=arr[j][3])
                arr[i][4]++;
        }
    }
    long long int max=arr[1][4];
    for(i=2;i<=n;i++)
    {
        if(arr[i][4]>max)
            max=arr[i][4];
    }
    cout<<max<<endl;
}
}
I am a beginner at this site,thanks in advance.
 
    