AlgoUniversity
  • Go Back
Discussion
Merge Elements :

Author

Manas

Difficulty Level : Medium

Submissions : 721

Asked In : BNY-Mellon

Marks :10

: 2 | : 6

Given an array X and an integer N. You can perform the following operation on the array elements: for any two elements in the array (a,b) you can merge elements b into a if 2a >= b. The numbers add together if merged.

You have to perform this operation until only one element remains. Return the number of positions possible for the final number.

Constraints:

1 <= t <= 10

1<= N <= 1000000

1 <= Xi <= 10^9

Input

First line contains integer t which is the number of test cases. For each test case:

First line contains an integer N. The next line contains N space separated integers.

Output

For each test case output one integer. corresponding to the number of possible positions.

Examples

Input
1
2
3 4
Output
2
Input
2
4
1 2 3 4
2
1 3
Output
4
1

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.