#include using namespace std; typedef long long ll; typedef pair PII; const int MAXN = 2e3 + 10; const int MM = 1e9 + 7; const ll INF = 1ll << 60; int n; ll a[MAXN], b[MAXN], s[MAXN]; ll f[MAXN][MAXN]; void upd(ll &x, ll y) { x = min(x, y); } void solve(int casi){ scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%lld", &a[i]); s[0] = 0; for (int i = 1; i <= n; i++) { scanf("%lld", &b[i]); s[i] = s[i - 1] + b[i]; } for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { f[i][j] = INF; } } f[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 0; j < i; j++) { // gugugu i upd(f[i][j + 1], f[i - 1][j]); // gan i if (f[i - 1][j] + a[i] <= s[i]) upd(f[i][j], f[i - 1][j] + a[i]); } } int ans = 0; for (int j = 0; j <= n; j++) { if (f[n][j] < INF) { ans = max(ans, n - j); } } printf("%d\n", ans); } int main(){ int T = 1; scanf("%d", &T); for (int i = 1; i <= T; i++) solve(i); return 0; }