#include <bits/stdc++.h>   using namespace std;   long long a[100005];   long long c[100005];   int main() {     int n, k;     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %lld , &a[i]);       a[i] -= k;     }     long long A;     scanf( %lld , &A);     priority_queue<long long, vector<long long>, greater<long long> > P;     long long cnt = 0;     long long ans = 0;     long long now = 0;     for (int i = 1; i <= n; i++) {       scanf( %lld , &c[i]);     }     for (int i = 1; i <= n; i++) {       P.push(c[i]);       if (a[i] > cnt) {         long long t;         if (a[i] < now)           t = 0;         else           t = ((a[i] - now) % A == 0 ? (a[i] - now) / A : (a[i] - now) / A + 1);         for (int j = 1; j <= t; j++) {           if (P.empty()) {             ans = -1;             break;           }           ans += P.top();           now += A;           P.pop();         }         cnt = a[i];         if (ans == -1) break;       }     }     printf( %lld , ans);   }   