Running Rivalry

Easy
2
33.3% Acceptance

Alice and Bob have taken up running and are interested in tracking their progress by comparing their daily distances.

For a stretch of NN days, Alice ran AiA_i meters and Bob ran BiB_i meters on day ii.

On any given day,

  • Alice feels discontent if Bob's distance is more than double hers, and content otherwise.
  • Bob feels discontent if Alice's distance is more than double his, and content otherwise.

For instance, on a specific day:

  • Should Alice run 200200 meters and Bob 500500, Alice would be discontent while Bob would be content.
  • Should Alice cover 500500 meters and Bob 240240, Alice would be content while Bob would be discontent.
  • If Alice runs 300300 meters and Bob 500500, both would find contentment.

Determine the number of days where both Alice and Bob felt content.

Input Format

  • The initial line of input presents a single integer TT, representing the count of test cases.
  • Each test case is divided into three lines.
    • The opening line of a test case states a single integer NN — the count of days.
    • The subsequent line lists NN integers separated by spaces A1,A2,,ANA_1, A_2, \ldots, A_N — the distances Alice ran each day.
    • The last line also lists NN integers separated by spaces B1,B2,,BNB_1, B_2, \ldots, B_N — the distances Bob ran each day.

Output Format

For every test case, report in a new line the tally of days when both Alice and Bob were content.

Constraints

  • 1T10001 \leq T \leq 1000
  • 1N1001 \leq N \leq 100
  • 1Ai,Bi1051 \leq A_i, B_i \leq 10^5

Sample Test Cases (with explanations)

Case #1:

Input:

4 3 100 200 300 300 200 100 4 1000 1000 1000 1000 400 500 600 1200 4 800 399 1400 532 2053 2300 3400 23 5 800 850 900 950 1000 600 800 1000 1200 1400

Output:

1 3 0 5

Explanation

Test case 11: Alice is discontent on the first day, as her 100100 meters is significantly less than Bob's 300300; Bob's distance being over twice of Alice's.
On the contrary, Bob is discontent on the third day.
The second day sees both Alice and Bob content, leading to the answer being 11.

Test case 22: Day 11 has Bob discontent but content on the remaining days, whereas Alice is content throughout, making them both content on three days — the second, third, and fourth days.

Test case 33: Days 1,2,31, 2, 3 see Alice discontent and day 44 sees Bob discontent.

Test case 44: Across all five days, both Alice and Bob are content.