#include #include using namespace std; typedef long long ll; typedef long double ld; #define int ll #define OVERLOAD_REP(_1, _2, _3, name, ...) name #define REP2(i, l, r) for (int i = (int)(l); i < (int)(r); i++) #define REP1(i, n) REP2(i, 0, n) #define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__) #define RREP2(i, l, r) for (int i = (int)(l)-1; i >= (int)(r); i--) #define RREP1(i, n) RREP2(i, n, 0) #define rrep(...) OVERLOAD_REP(__VA_ARGS__, RREP2, RREP1)(__VA_ARGS__) #define all(...) begin(__VA_ARGS__), end(__VA_ARGS__) #define rall(...) rbegin(__VA_ARGS__), rend(__VA_ARGS__) #define debug(x) cerr << #x << ": " << (x) << endl #define pb push_back #define mp make_pair #define mt make_tuple const int INF = 4e18; const int MOD = 1e9 + 7; const int MOD2 = 998244353; template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template void input(T&... args) { ((cin >> args), ...); } template void print(T... args) { ((cout << args << " "), ...); } template void println(T... args) { print(args...); cout << endl; } signed main() { int N, M, W; input(N, M, W); vector A(N); rep(i, N) input(A[i]); vector B(M); rep(i, M) input(B[i]); vector C(M); rep(i, M) input(C[i]); sort(rall(A)); vector A_acc(N+1); rep(i, N) A_acc[i+1] = A_acc[i] + A[i]; int ans = 0; rep(i, 1 << M) { int weight = 0; int value = 0; rep(j, M) { if (i >> j & 1) { weight += B[j]; value += C[j]; if (W < weight) break; } } if (W < weight) break; chmax(ans, value + A_acc[min(W - weight, N)]); } println(ans); }