#include <bits/stdc++.h>   using namespace std;   int n, m, d[1002], s[1002], t, f, sum, k;   int main() {     cin >> m >> k;     for (int i = 2; i <= m + 1; i++) {       cin >> d[i];     }     for (int i = 1; i <= m; i++) {       cin >> s[i];     }     for (int i = 1; i <= m; i++) {       f += s[i];       t = max(t, s[i]);       while (f < d[i + 1]) {         sum += k, f += t;       }       sum += d[i + 1], f -= d[i + 1];     }     cout << sum;   }   