#include using namespace std; using ll = long long; #define rep(i,m,n) for(int i=m; i bool chmin(T& a, T b){ if(a > b){a = b; return true;} return false; } template bool chmax(T& a, T b){ if(a < b){a = b; return true;} return false; } template T gcd(T a, T b){ return a % b ? gcd(b, a % b) : b; } template T lcm(T a, T b){ return a / gcd(a, b) * b; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; ll W; cin >> N >> M >> W; vector A(N), B(M), C(M); rep(i, 0, N) cin >> A[i]; rep(i, 0, M) cin >> B[i]; rep(i, 0, M) cin >> C[i]; sort(all(A), greater()); vector sum_A(N+1, 0LL); rep(i, 0, N) sum_A[i+1] = sum_A[i] + A[i]; ll max_value = -1LL; for(int bit = 0; bit < (1 << M); ++bit){ ll value = 0LL, weight = 0LL; rep(i, 0, M){ if(bit & (1 << i)){ value += C[i]; weight += B[i]; } } if(weight > W) continue; value += sum_A[min(ll(N), W - weight)]; chmax(max_value, value); } cout << max_value << endl; return 0; }