#include <bits/stdc++.h>   using namespace std;   long long n, m, res, t, k, o;   long long a[1000100], b[1000100];   priority_queue<int, vector<int>, greater<int> > q;   int main() {     scanf( %lld %lld , &n, &k);     for (long long i = 1; i <= n; i++) {       scanf( %lld , &a[i]);     }     scanf( %lld , &m);     for (long long i = 1; i <= n; i++) {       scanf( %lld , &b[i]);     }     res = 0;     for (int i = 1; i <= n; i++) {       q.push(b[i]);       while (k < a[i] && !q.empty()) {         k = k + m;         res += q.top();         q.pop();       }       if (k < a[i]) {         res = -1;         break;       }     }     printf( %lld n , res);   }   