#include #include #include using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) void chmin(int &l, int r){if(l>r)l=r;} int main(){ int n; cin>> n; vector a(n+1); rep(i, n) cin>> a[i+1]; vector x(n+1); rep(i, n) cin>> x[i+1]; vector y(n+1); rep(i, n) cin>> y[i+1]; const int inf=1e8; vector dp(n+1, inf); dp[0]=0; for(int i=1; i<=n; i++){ for(int j=1; j<=i; j++){ chmin(dp[i], dp[j-1]+y[j]+abs(x[j]-a[i])); } } cout<< dp[n]<< endl; return 0; }