#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int N, M; ll W; int main() { cin >> N >> M >> W; vector A(N),S(N+1,0),B(M),C(M); for(int i = 0; i < N; ++i) cin >> A[i]; sort(A.begin(),A.end(),greater()); for(int i = 0; i < N; ++i) S[i+1] = S[i]+A[i]; for(int i = 0; i < M; ++i) cin >> B[i]; for(int i = 0; i < M; ++i) cin >> C[i]; ll mx = 0; for(int i = 0; i < 1<>j&1) == 0) continue; sw += B[j]; sv += C[j]; } if(sw <= W) { if(W-sw > N) mx = max(mx, sv+S[N]); else mx = max(mx, sv+S[W-sw]); } } cout << mx << endl; }