You are given the following:
You can place a stone into a box only when the size of the box is at least double the size of the stone. A box can contain only 1 stone at a time.
Task
You have to determine the maximum number of stones that can be put in boxes.
Note: 0-based indexing is followed.
Example
Assumption
Approach
Therefore the maximum number of stones that can be put into the boxes is 2.
Note: There are other ways possible but the maximum number of stones that can be stored in the boxes is 2.
Function description
Complete the solve function provided in the editor. This function takes the following 4 parameters and returns the answer.
Input format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
Output format
Print a single integer denoting the maximum number of stones that can be stored into the boxes.
Constraints
1≤N≤1051≤M≤1051≤Ai≤1091≤Bi≤109
Code snippets (also called starter code/boilerplate code)
This question has code snippets for C, CPP, Java, and Python.
Given
Approach
Therefore the maximum number of stones that can be put into the boxes is 2.
Note: There are other ways possible but the maximum number of stones that can be stored in the boxes is 2.