using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Threading; using static util; class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; var solver = new Solver(sw); // var t = new Thread(solver.solve, 1 << 26); // 64 MB // t.Start(); // t.Join(); solver.solve(); sw.Flush(); } } class Solver { StreamWriter sw; Scan sc; void Prt(string a) => sw.WriteLine(a); void Prt(IEnumerable a) => Prt(string.Join(" ", a)); void Prt(params object[] a) => Prt(string.Join(" ", a)); public Solver(StreamWriter sw) { this.sw = sw; this.sc = new Scan(); } public void solve() { int n = sc.Int; var a = sc.IntArr; var b = sc.IntArr; var d = sc.IntArr; Array.Sort(d); int ok = 0, ng = n + 1; while (ng - ok > 1) { int m = (ok + ng) / 2; var f = new bool[1]; f[0] = true; for (int i = 1; i <= m; i++) { var nf = new bool[i + 1]; for (int j = 0; j < i; j++) { if (!f[j]) continue; if (a[j] + b[i - j] >= d[m - i]) nf[j] = true; if (a[j + 1] + b[i - j - 1] >= d[m - i]) nf[j + 1] = true; } f = nf; } if (f.Any(x => x)) ok = m; else ng = m; } Prt(ok); } } static class util { public static readonly int M = 1000000007; } class Scan { StreamReader sr; public Scan() { sr = new StreamReader(Console.OpenStandardInput()); } public Scan(string path) { sr = new StreamReader(path); } public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public string Str => sr.ReadLine().Trim(); public int[] IntArr => StrArr.Select(int.Parse).ToArray(); public long[] LongArr => StrArr.Select(long.Parse).ToArray(); public double[] DoubleArr => StrArr.Select(double.Parse).ToArray(); public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries); bool eq() => typeof(T).Equals(typeof(U)); T ct(U a) => (T)Convert.ChangeType(a, typeof(T)); T cv(string s) => eq() ? ct(int.Parse(s)) : eq() ? ct(long.Parse(s)) : eq() ? ct(double.Parse(s)) : eq() ? ct(s[0]) : ct(s); public void Multi(out T a) => a = cv(Str); public void Multi(out T a, out U b) { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); } public void Multi(out T a, out U b, out V c) { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); } public void Multi(out T a, out U b, out V c, out W d) { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); } }