Question: Debugging Merchant You are given a code for the following problem statement. However, the solution fails the test cases because there are bugs in the

Debugging Merchant
You are given a code for the following problem statement. However, the solution fails the test cases because there are bugs in the code. Your task is to find and fix all the bugs so that it passes all the test cases.
10
11
Statement
A merchant has a store of capacity M. He has M units of a product in his store. On each day, he can do one of the following:
If there is at least one item in the store, he can sell the item. The number of units reduces by 1.
Purchase an item from the wholesaler. The number of units Increases by 1. If he already has M units in his store, buying an Item will not increase the current number of units in the store. This means buying any more items will lead to waste.
The merchant wants to sell at least R units within D days. Check if it is possible.
Function description
Complete the solution() function. The function takes the following 3 parameters and returns the solution:
Function description
Complete the solution() function. The function takes the following 3 parameters and returns the solution:
M. Represents the storage capacity
R. Represents the number of units desired to be sold
D. Represents the day limit
10
Input format for custom testing
Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code.
The first line contains M, which denotes the storage capacity.
The second line contains R, denoting the number of units desired to be sold.
The third line contains D. denoting the number of days.
Output format
Print YES if it is possible to sell the items. Else print NO. The checker is case-sensitive.
Constraints
1M,R, D10
Sample input Sample output
10 NO
5
3
Explanation
Given
Input
C
M-10
R-5
D=3
Output: NO
Approach
There is no possible way to sell 5 items in 3 days
Note:
Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement
Limits
Explanation
Given
Input
M=10
R-5
D=3
Output: NO
Approach
There is no possible way to sell 5 items in 3 days.
Note:
Your code must be able to print the sample output from the provided sample Input However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.
Limits
Time Limit: 5.0 sec(s) for each input file
Mernory Limit: 256 MB
Source Limit: 1024 KB
Scoring
Score is assigned if any testcase passes
Allowed Languages
Python 3. Python 3.8
give me the code in the given below formate
mod=10**9+7
def solution (M, R, D):
req=min(M,R)
R+=M
if R>=0:
req/=2*R
if req

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!