# Chef and Churu(FNCS) getting wrong answer

Hi friends, I’ve written this code for Chef and Churu(FNCS) problem of Nov14 long challenge. I’ve checked it with many different cases on my machine and it always gives a correct answer. But when I submit it on codechef if gives wrong answer(WA). Please help…here is my code

``````#include<iostream>
using namespace std;
int main()
{
long n,q,e=0;
int i,j,m,p,t,i1,i2,i3,i4;
cin>>n;
if(n>=1 && n<=100000)
{
long a[n],b[n],c[n],d[n];
for(i=0;i<n;i++)
{
cin>>a[i];
if(a[i]>=1 && a[i]<=1000000000)
e++;
}
if(e==n)
{
for(i=0;i<n;i++)
{    int sum=0;
cin>>m>>p;
if((m>=1 && m<=n) && (p>=m && p<=n))
{
for(j=m;j<=p;j++)
sum=sum+a[j-1];
b[i]=sum;
c[i]=m;
d[i]=p;
}

}

cin>>q;
if(q>=1 && q<=100000)
{
int x[q];
for(i=0;i<q;i++)
{
cin>>t;
if(t==1)
{
cin>>i1>>i2;
if((i1>=1 && i1<=n) && (i2>=1 && i2<=1000000000))
{

for(j=0;j<n;j++)
{
if(c[j]<=i1 && d[j]>=i1)
{
b[j]=b[j]-a[i1-1]+i2;

}
}
a[i1-1]=i2;
x[i]=-1;
continue;
}
}
else
{
cin>>i3>>i4;
if((i3>=1 && i3<=n) && (i4>=i3 && i4<=n))
{
int sum=0;
for(j=i3;j<=i4;j++)
{
sum=sum+b[j-1];
}
x[i]=sum;
}

}
}

for(i=0;i<q;i++)
{
if(x[i]==-1)
continue;
else
cout<<x[i]<<endl;
}
}

}
}
return 0;
}``````