i tried to build a faster solution but getting sigsegv can anyone help.
thanks in advance!!
my solution: CodeChef: Practical coding for everyone
problem link: LELEMON Problem - CodeChef
i tried to build a faster solution but getting sigsegv can anyone help.
thanks in advance!!
my solution: CodeChef: Practical coding for everyone
problem link: LELEMON Problem - CodeChef
for(j=0;j< m;j++)
{
if(a[j]>=p[j])
netsum+=sum[j];
else
{
for(int y=p[j]-1;y>=p[j]-a[j];y--)<Br>
netsum+=botal[j][y];<Br>
}<Br>
}
Here m is in the range 1<=m<=10000 and the size of a[] and p[] are 102,101 respectively.
When j becomes greater than or equal to size of arrays,i.e.,j>=size, it causes runtime error.
THE CORRECTION:
for(j=0;j<101;j++)<Br>
{
if(a[j]>0)
{
if(a[j]>=p[j])
netsum+=sum[j];<Br>
else<Br>
{<Br>
for(int y=p[j]-1;y>=p[j]-a[j];y--)<Br>
netsum+=botal[j][y];<Br>
}<Br>
}<BR>
}