Running Comparison CodeChef Solution

We Are Discuss About CODECHEF SOLUTION

Running Comparison CodeChef Solution

Running Comparison CodeChef Solution

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

Problem

Alice and Bob recently got into running, and decided to compare how much they ran on different days.

They each ran for  days — on the ��ℎ day, Alice ran �� meters and Bob ran �� meters.

On each day,

  • Alice is unhappy if Bob ran strictly more than twice her distance, and happy otherwise.
  • Similarly, Bob is unhappy if Alice ran strictly more than twice his distance, and happy otherwise.

For example, on a given day

  • If Alice ran 200 meters and Bob ran 500, Alice would be unhappy but Bob would be happy.
  • If Alice ran 500 meters and Bob ran 240, Alice would be happy and Bob would be unhappy.
  • If Alice ran 300 meters and Bob ran 500, both Alice and Bob would be happy.

On how many of the  days were both Alice and Bob happy?

Input Format

  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of three lines of input.
    • The first line of each test case contains a single integer  — the number of days.
    • The second line of each test case contains  space-separated integers �1,�2,…,�� — the distances run by Alice on the  days.
    • The third line of each test case contains  space-separated integers �1,�2,…,�� — the distances run by Bob on the  days.

Output Format

For each test case, output on a new line the number of days when both Alice and Bob were happy.

Constraints

  • 1≤�≤1000
  • 1≤�≤100
  • 1≤��,��≤105

Sample 1:

Input

Output

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
1
3
0
5

Explanation:

Test case 1: Alice is unhappy on the first day, since she ran 100 meters but Bob ran 300; and 300 is more than twice of 100.
Similarly, Bob is unhappy on the third day.
Both Alice and Bob are happy on the second day, so the answer is 1.

Test case 2: Bob is unhappy on day 1 and happy on every other day, while Alice is happy on every day. So, they’re both happy on three days — the second, third, and fourth.

Test case 3: Alice is unhappy on days 1,2,3 and Bob is unhappy on day 4.

Test case 4: Alice and Bob are both happy on all five days.

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

 

SOLUTION

Here Discuss About Solve Running Comparison CodeChef Solution

SOLUTION

Running Comparison CodeChef Solution

SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *