#![allow(non_snake_case)] fn main() { #[allow(unused_imports)] use std::cmp::{min, max}; use std::io::{Read, Write, BufWriter}; let mut a = Vec::new(); std::io::stdin().read_to_end(&mut a).unwrap(); let a = String::from_utf8(a).unwrap(); let mut a = a.split_whitespace(); let mut b = BufWriter::new(std::io::stdout()); macro_rules! yomu { () => (a.next().unwrap().parse().unwrap()) } macro_rules! kaku { ($($arg:tt)*) => (writeln!(b, $($arg)*).unwrap()) } let N: usize = yomu!(); let mut A: Vec = Vec::new(); let mut B: Vec = Vec::new(); let mut D: Vec = Vec::new(); for _ in 0..N+1 { A.push(yomu!()); } for _ in 0..N+1 { B.push(yomu!()); } for _ in 0..N { D.push(yomu!()); } D.sort(); D.reverse(); let mut l = 0; let mut r = N + 1; while r - l > 1 { let m: usize = ((l + r) / 2) as usize; let mut dp = vec![vec![false; m+1]; m+1]; dp[0][0] = true; for i in 0..m { for j in 0..m { if i+j+N-m >= N { break } if !dp[i][j] { break } if A[i+1] + B[j] >= D[N-m+i+j] { dp[i+1][j] = true; } if A[i] + B[j+1] >= D[N-m+i+j] { dp[i][j+1] = true; } } } let mut saidai = 0; for i in 0..m+1 { for j in 0..m+1 { if dp[i][j] { saidai = max(saidai, i+j); } } } if saidai == m { l = m; } else { r = m; } } kaku!("{}", l); }