#![allow(dead_code, unused_imports, unused_macros, non_snake_case)] fn main() { let [N, M, W] = read_words::()[..] else { return }; let mut A = read_words::(); A.sort(); A.push(0); A.reverse(); for i in 0 .. N { A[i + 1] += A[i]; } let B = read_words::(); let C = read_words::(); let mut ans = 0; for bits in 0 .. 1 << M { let mut value_sum = 0; let mut weight_sum = 0; for j in 0 .. M { if bits & 1 << j != 0 { weight_sum += B[j]; value_sum += C[j]; } } if weight_sum > W { continue; } value_sum += A[N.min(W - weight_sum)]; ans = ans.max(value_sum); } println!("{ans}"); } type Int = i64; const MOD: Int = 1_000_000_007; const INF: Int = 1_000_000_000; const YESNO: [&'static str; 2] = ["Yes", "No"]; fn read_line() -> String { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).ok(); buf } fn read_words() -> Vec where T::Err: std::fmt::Debug { read_line().split_whitespace().map(|x| T::from_str(x).unwrap() ).collect() } fn yes() { println!("{}", YESNO[0]); } fn no() { println!("{}", YESNO[1]); } fn yesno(c: bool) { println!("{}", if c { YESNO[0] } else { YESNO[1] }); }