#include #include using namespace std; #define DEBUG(x) cerr<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair template pair operator+(const pair &s, const pair &t) { return pair(s.first + t.first, s.second + t.second); } template pair operator-(const pair &s, const pair &t) { return pair(s.first - t.first, s.second - t.second); } template ostream& operator<<(ostream& os, pair p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i,n) for(int i=0;i<(n);i++) #define rep1(i,n) for(int i=1;i<=(n);i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define rrep1(i,n) for(int i=(n);i>0;i--) #define REP(i,a,b) for(int i=a;i bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const double pi = 3.14159265358979323846; #define Sp(p) cout<> n; vl a(n + 1), b(n + 1), d(n); rep (i, n + 1) cin >> a[i]; rep (i, n + 1) cin >> b[i]; rep (i, n) cin >> d[i]; sort(all(d)); reverse(all(d)); int ok = 0, ng = n + 1; while (ok + 1 < ng) { int nn = (ok + ng) / 2; int musi = n - nn; vii dp(nn + 1, vi(nn + 1, -inf)); dp[0][0] = 0; rep (i, nn) { rep (j, nn + 1) { if (dp[i][j] <= -inf) continue; int k = dp[i][j] - j; if (d[i + musi] <= a[j + 1] + b[k]) { chmax(dp[i + 1][j + 1], dp[i][j] + 1); } if (d[i + musi] <= a[j] + b[k + 1]) { chmax(dp[i + 1][j], dp[i][j] + 1); } } } int ans = 0; rep (j, nn + 1) { chmax(ans, dp[nn][j]); } if (ans == nn) ok = nn; else ng = nn; } cout << ok << endl; }