#include #include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef long double ld; typedef pair P; ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const static_modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const dynamic_modint& a) {os << a.val(); return os;} template istream& operator>>(istream& is, vector& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template ostream& operator<<(ostream& os, const pair& p){os << p.first << ' ' << p.second; return os;} template ostream& operator<<(ostream& os, const vector& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const vector>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} template void chmin(T& a, T b){a = min(a, b);} template void chmax(T& a, T b){a = max(a, b);} using mint = modint998244353; int main(){ int n, m; long long w; cin >> n >> m >> w; vector a(n); cin >> a; vector b(m); vector c(m); cin >> b >> c; vector s(n + 1); sort(a.rbegin(), a.rend()); rep(i, n) s[i + 1] = s[i] + a[i]; long long ans = 0; rep(bit, 1 << m){ long long tot_weight = 0; long long tot_value = 0; rep(i, m){ if((bit >> i) & 1){ tot_weight += b[i]; tot_value += c[i]; } } if(tot_weight > w) continue; if(tot_weight + n <= w) tot_value += s[n]; else tot_value += s[w - tot_weight]; chmax(ans, tot_value); } cout << ans << "\n"; return 0; }