#include #include using namespace std; #include using namespace atcoder; using ll = long long; #define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i) #define rep(i, n) reps(i, 0, n) #define all(a) (a).begin(), (a).end(); //なんかstd::vectorの挙動を修正できるやつ /* alias */ using ull = unsigned long long; using ll = long long; using vi = vector; using vl = vector; using vll = vector; using vvi = vector; using vvl = vector; using vvll = vector; using vs = vector; using pii = pair; #define debug(x) \ cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << "\033[m" \ << endl; const ll minf = -1e10; int main() { int n, m, w; cin >> n >> m >> w; vll a(n + 1), b(n + 1), c(m + 1), d(m + 1); rep(i, n) cin >> a[i + 1]; rep(i, n) cin >> b[i + 1]; rep(i, m) cin >> c[i + 1]; rep(i, m) cin >> d[i + 1]; vvll dp(n + 1, vll(w + 1, minf)); dp[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= w; j++) { if (j < a[i]) { dp[i][j] = dp[i - 1][j]; } else if (j <= w) dp[i][j] = max(dp[i - 1][j - a[i]] + b[i], dp[i - 1][j]); for (int k = 1; k <= m; k++) { if (j - c[k] >= 0) dp[i][j - c[k]] = max(dp[i][j - c[k]], dp[i][j] - d[k]); } } } ll ans = -1000; rep(i, w + 1) ans = max(ans, dp[n][i]); cout << ans << endl; return 0; }