#include #include #include int main(){ int n, m; long long w; std::cin>>n>>m>>w; std::vector a(n); std::vector b(m); std::vector c(m); for(int i = 0; i < n; i++){ std::cin>>a[i]; } for(int i = 0; i < m; i++){ std::cin>>b[i]; } for(int i = 0; i < m; i++){ std::cin>>c[i]; } std::sort(a.rbegin(), a.rend()); std::vector sum(n+1); for(int i = 0; i < n; i++){ sum[i+1] = sum[i] + a[i]; } // タイプYを選ぶ全パターン列挙 typedef struct { long long weight; long long cost; } knapsack_t; std::vector patterns; for(int bit = 0; bit < (1<>i&1){ knapsack.weight += b[i]; knapsack.cost += c[i]; } patterns.push_back(knapsack); } long long ans = 0; for(auto p: patterns) if(p.weight <= w){ int remain = std::min(w-p.weight, (long long)n); ans = std::max(ans, p.cost + sum[remain]); } std::cout << ans << std::endl; }