I am getting Wrong Answer although it is compiling and giving the right answer.

Problem Link

https://www.codechef.com/problems/DANOW

My code

#include

using namespace std;

int main(){

int n , q;

int i , j;

int l , r;

int x , y;

int sum = 0;

cin >> n >> q;

int a[n],b[n];

for(i = 1;i <= n;i++){

cin >> a[i];

}

for(j = 1;j <= n;j++){

cin >> b[j];

}

```
while(q--){
cin >> l >> r ;
sum = 0;
for(x = l; x <= r; x++){
sum = sum + (a[x]*b[x]);
}
cout << sum << endl;
}
```

}

And the submitted answer link

https://www.codechef.com/viewsolution/25029277