#include <bits/stdc++.h>   using namespace std;   const int maxN = (int)1e4 + 10;   int n, w, b, x;   long long dp[1005][maxN];   int c[maxN];   int cost[maxN];   int main() {     cin >> n >> w >> b >> x;     for (int i = 1; i <= n; i++) cin >> c[i];     for (int i = 1; i <= n; i++) cin >> cost[i];     memset(dp, -1, sizeof dp);     dp[0][0] = w;     for (int i = 1; i <= n; i++) {       for (int j = 0; j < maxN; j++) {         long long cur_bal = dp[i - 1][j];         if (cur_bal == -1) continue;         for (int k = 0; k <= c[i]; k++) {           if (1LL * k * cost[i] > cur_bal) continue;           dp[i][j + k] = max(min(cur_bal - (1LL * k * cost[i]) + x,                                  1LL * w + (1LL * b * (j + k))),                              dp[i][j + k]);         }       }     }     for (int i = maxN - 1; i >= 0; i--) {       if (dp[n][i] != -1) {         cout << i;         return 0;       }     }     return 0;   }   