#include using namespace std; using ll = long long; #ifdef LOCAL #include "../algo/debug.hpp" #else #define debug(...) void(0) #endif void solve() { ll n, m, w; cin >> n >> m >> w; vector a(n), b(m), c(m); for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < m; i++) cin >> b[i]; for(int i = 0; i < m; i++) cin >> c[i]; sort(a.begin(), a.end(), greater<>{}); vector pref(n + 1, 0); for(int i = 0; i < n; i++) pref[i + 1] = pref[i] + a[i]; ll ans = 0; for(int bit = 0; bit < (1 << m); bit++) { ll nowb{}, nowc{}; for(int i = 0; i < m; i++) { if(bit & (1 << i)) { nowb += b[i]; nowc += c[i]; } } if(nowb <= w) { ll rt = w - nowb; ans = max(ans, nowc + pref[min(rt, n)]); } } cout << ans << endl; } int main() { int T = 1; // cin >> T; while (T--) { solve(); } return 0; }