please help me with c++
please help me with c++
please help me with c++please help me with c++
please help me with c++please help me with c++
please help me with c++
my code
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int a[N],b[N],c[N],x,n;
int main(){
cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++){
cin>>x;
if(a[i]-x<=0)b[i]=a[i]-x;
else c[i]=x-a[i];
}
int ans=0;
for(int i=1; i <= n; i++){
if(b[i]>b[i-1]) ans+=b[i]-b[i-1];
}
for(int i=1; i <= n; i++){
if(c[i]>c[i-1]) ans+=c[i]-c[i-1];
}
printf("%d",ans);
return 0;
}