#include #include #include #include using namespace std; int main() { int n; cin >> n; int n1 = n+1; vector a(n1), b(n1), d(n); for (int i = 0; i < n1; i++) cin >> a[i]; for (int i = 0; i < n1; i++) cin >> b[i]; for (int i = 0; i < n; i++) cin >> d[i]; sort(d.begin(), d.end()); vector> es(n1); for (int i = 0; i < n1; i++) { for (int j = 0; j < n1; j++) { int p = i + j; if (p > n) { continue; } es[p].push_back(i * n1 + j); } } vector m(n1*n1, 0); for (int p = n; p > 0; p--) { for (int e : es[p]) { int i = e / n1; int j = e % n1; int s = m[e]; int r = a[i] + b[j]; if (s < n && d[s] <= r) { s++; } int u = e - 1; if (u >= 0 && s > m[u]) { m[u] = s; } int v = e - n1; if (v >= 0 && s > m[v]) { m[v] = s; } } } cout << m[0] << endl; return 0; }