#include #include #include using namespace std; int main() { int 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]; } vector> t; for (int i = 0; i < N; ++i) { t.push_back({static_cast(A[i]) * 1000000000000000000LL, i}); } for (int i = 0; i < M; ++i) { t.push_back({static_cast(C[i]) * 1000000000000000000LL / B[i], 10000000 + i}); } sort(t.begin(), t.end()); long long ans = 0; int weight = 0; for (int i = t.size() - 1; i >= 0; --i) { long long tanka = t[i].first; int ind = t[i].second; int omosa; int value; if (ind >= 10000000) { ind -= 10000000; omosa = B[ind]; value = C[ind]; } else { omosa = 1; value = A[ind]; } if (weight + omosa <= W) { weight += omosa; ans += value; } else { if (omosa == 1) { cout << ans << endl; return 0; } } } cout << ans << endl; return 0; }