// yuki 949 飲酒プログラミングコンテスト // 2019.12.12 bal4u #include #include int getchar_unlocked(void); #define gc() getchar_unlocked() int in() { // 整数の入力 int n = 0; int c; do c = gc(); while (isspace(c)); if (c == '-') { c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return -n; } do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return n; } void Qsort(int *a, int l, int r) { int i, j, m, t; i = l, j = r, m = a[(l+r) >> 1]; while (1) { while (a[i] < m) i++; while (m < a[j]) j--; if (i >= j) break; t = a[i], a[i] = a[j], a[j] = t; i++, j--; } if (l+1 < i) Qsort(a, l, i-1); if (j+1 < r) Qsort(a, j+1, r); } int N; int A[3005], B[3005]; int D[3005]; int main() { int i, j, a, b, s, ans; N = in(); for (i = 0; i <= N; ++i) A[i] = in(); for (i = 0; i <= N; ++i) B[i] = in(); for (i = 1; i <= N; ++i) D[i] = in(); Qsort(D, 1, N), D[0] = -200005; j = N; a = b = 0, ans = 0, A[N+1] = B[N+1] = -100002; while (ans < N && a <= N && b <= N) { if (A[a]+B[b+1] >= A[a+1]+B[b]) s = A[a]+B[++b]; else s = A[++a]+B[b]; while (s < D[j]) --j; if (j == 0) break; ++ans, --j; } printf("%d\n", ans); return 0; }