#include using namespace std; template struct SegTree{ using FX = function; // X•X -> X となる関数の型 int n; FX fx; const X ex; vector dat; SegTree(int n_, const FX &fx_, const X &ex_) : n(), fx(fx_), ex(ex_){ int x = 1; while(n_ > x){ x *= 2; } n = x; dat.assign(n * 2, ex); } X get(int i) const { return dat[i + n]; } void set(int i, X x){ dat[i + n] = x; } void build(){ for(int k = n - 1; k >= 1; k--) dat[k] = fx(dat[k * 2], dat[k * 2 + 1]); } void update(int i, X x){ i += n; dat[i] = x; while(i > 0){ i >>= 1; // parent dat[i] = fx(dat[i * 2], dat[i * 2 + 1]); } } X query(int a, int b){ X vl = ex; X vr = ex; int l = a + n; int r = b + n; while(l < r){ if(l & 1) vl = fx(vl, dat[l++]); if(r & 1) vr = fx(dat[--r], vr); l >>= 1; r >>= 1; } return fx(vl, vr); } X operator [](int i) const { return dat[i + n]; } }; const long long INF = 1LL << 60; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, k; cin >> n >> m >> k; vector c(n), a(m); for(int i = 0; i < n; i++){ cin >> c[i]; c[i]--; } for(int i = 0; i < m; i++){ cin >> a[i]; } auto fx = [](long long a, long long b){ return min(a, b); }; SegTree seg(m, fx, INF); for(int i = 0; i < m; i++){ seg.update(i, a[i] * k); } for(int i = 0; i < k; i++){ seg.update(c[i], seg[c[i]] - a[c[i]]); } long long ans = seg.query(0, m); for(int i = 0; i < n - k; i++){ seg.update(c[i], seg[c[i]] + a[c[i]]); seg.update(c[i + k], seg[c[i + k]] - a[c[i + k]]); ans = min(ans, seg.query(0, m)); } cout << ans << endl; }