#include <bits/stdc++.h>   using namespace std;   long long n, W, B, X, dp[1001][10001], c[1001], cum[1001], cost[1001];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> n >> W >> B >> X;     for (int i = 0; i < n; i++) {       cin >> c[i];       if (i == 0)         cum[i] = c[i];       else         cum[i] = cum[i - 1] + c[i];     }     for (int i = 0; i < n; i++) cin >> cost[i];     for (int i = 0; i < 1001; i++)       for (int j = 0; j < 10001; j++) dp[i][j] = 10000000000;     dp[0][0] = W;     for (int i = 0; i <= c[0]; i++) {       if (W >= i * cost[0]) dp[0][i] = W - i * cost[0];     }     for (int i = 1; i < n; i++) {       for (int j = 0; j <= cum[i]; j++) {         for (int k = 0; k <= min((long long)j, c[i]); k++) {           if (dp[i - 1][j - k] != 10000000000) {             if (min(dp[i - 1][j - k] + X, W + (j - k) * B) - k * cost[i] >= 0) {               dp[i][j] =                   max((dp[i][j] == 10000000000 ? 0 : dp[i][j]),                       min(dp[i - 1][j - k] + X, W + (j - k) * B) - k * cost[i]);             }           }         }       }     }     for (int i = cum[n - 1]; i >= 0; i--) {       if (dp[n - 1][i] != 10000000000) return cout << i, 0;     }     return 0;   }   