#include using namespace std; #define rep(i, n) for(int i=0; i #include //vectorの中身を空白区切りで出力 template void print1(vector v) { for (int i = 0; i < v.size(); i++) { cout << v[i]; if (i < v.size() - 1) { cout << " "; } } } //vectorの中身を改行区切りで出力 template void print2(vector v) { for (auto x : v) { cout << x << endl; } } //二次元配列を出力 template void printvv(vector> vv) { for (vector v : vv) { print1(v); cout << endl; } } //vectorを降順にソート template void rsort(vector &v) { sort(v.begin(), v.end()); reverse(v.begin(), v.end()); } //昇順priority_queueを召喚 template struct rpriority_queue { priority_queue, greater> pq; void push(T x) { pq.push(x); } void pop() { pq.pop(); } T top() { return pq.top(); } size_t size() { return pq.size(); } bool empty() { return pq.empty(); } }; int main() { ll N, M, W; cin >> N >> M >> W; vector X(N); rep(i, N) { cin >> X[i]; } vector> Y(M, vector(2)); rep(i, M) { cin >> Y[i][0]; } rep(i, M) { cin >> Y[i][1]; } rsort(X); vector sum(N + 1); sum[0] = 0; rep(i, N) { sum[i + 1] = sum[i] + X[i]; } ll ans = 0; for (int i = 0; i < (1 << M); i++) { bitset<20> b = i; ll w = 0, v = 0; rep(j, M) { if (b[j]) { w += Y[j][0]; v += Y[j][1]; } } if (w <= W) { v += sum[min(W - w, N)]; ans = max(ans, v); } } cout << ans << endl; }