#include #include using namespace std; using namespace atcoder; using ll = long long; using ull = unsigned long long; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const vector dx = {0,0,1,-1}; const vector dy = {1,-1,0,0}; const ll INF = 1e18; const ll inf = 1e8; const ll MOD = 998244353; int main(){ ll 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]; sort(a.rbegin(),a.rend()); vector s(n); s[0] = a[0]; for(int i = 1; i < n; i++) s[i] = s[i-1] + a[i]; ll ans = -1; for (int bit = 0; bit < (1 << m); ++bit) { ll p = w, v = 0; for (int i = 0; i < m; ++i) { if (bit & (1 << i)) { p -= b[i]; v += c[i]; } } if(p<0) break; if(p>=n){ v += s[n-1]; }else if(p==0){ ; } else{ v += s[p-1]; } if(v == 127){ cout << p << endl; return 0; } chmax(ans,v); } cout << ans << endl; }