#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int N, M; ll A[200009], B[200009]; ll C[200009]; int main() { cin >> N >> M; ll sum = 0; for(int i = 0; i < N; ++i) cin >> A[i]; for(int i = 0; i < M; ++i) cin >> B[i]; for(int i = 0; i < N; ++i) { cin >> C[i]; sum += C[i]; } vector add(N,0); for(int i = 1; i < N; ++i) add[i] = add[i-1]+B[(i-1)%M]; // for(int i = 0; i < N; ++i) cout << add[i] << endl; map mp; for(int i = 0; i < N; ++i) mp[A[i]-add[i]] += C[i]; ll ans = 1e18; for(auto [k, v] : mp) ans = min(ans, sum-v); cout << ans << endl; }