THe Lead Game(TLG) : How to resolve SIGSEGV error from this program? I am using c++.

I know what is an SIGSEGV error as I read about it while trying to figure this out by myself. But, the main problem is I can’t figure out how its occurring in this program.Please try to help me out. I am getting the right answer on my system as its supposed to be. Just can’t get it accepted due to this runtime error.

#include<iostream>
using namespace std;

int mod(int a){
int k=0;
if(a>=0)
k=a;
else
k=-a;

return k;
}

int main(){
int t,i,n=0,news,p=0,win=2;
int p1[99],p2[99],lead[99],modLead[99];
cin>>t;
for(i=0;i<t;i++){
	cin>>p1[i];
	cin>>p2[i];
	n=n+p1[i]-p2[i];
	lead[i]=n;
	modLead[i]=mod(lead[i]);
	
}

news= modLead[0];
for(i=1;i<t;i++){
	if(modLead[i]>news){
		news=modLead[i];
		p=i;
	}
}

if(modLead[p]>0)
win=1;
cout<<win<<" "<<modLead[p];

return 0;
}

Since in your program all array have length of 99 but N which is t in your program is <=10000. Please refer to constraints carefully.

I tried what you said. I made the array length 10001.But , now it says “Wrong Answer”.

Then your algorithm is wrong. Try to use some other approach or modify your program.