InterviewBit Academy is now Scaler!
InterviewBit Academy is now Scaler Academy!

Distribute candies

Problem Description
<div id=problem_description_markdown_content_value style=”background-color: #f9f9f9; padding: 5px 10px; “><p>Akash wants to distribute candies on his birthday. There are A people and he has two types of candies. B candies of the first type and C candies of the second type.

He wants to distribute candies in such a way that no person has candies of both types and each person has at least one candy.

Let X denotes the minimum candies among all people after distribution of candies.

Find the maximum X.


Problem Constraints
<div id=problem_constraints_markdown_content_value style=”background-color: #f9f9f9; padding: 5px 10px; “>2<=A<=B+C



Input Format
<div id=input_format_markdown_content_value style=”background-color: #f9f9f9; padding: 5px 10px; “>First argument is an integer A denoting number of people.

Second argument is an integer B denoting number of candies of first type.

Third argument is an integer C denoting number of candies of second type.</div>

Output Format
<div id=output_format_markdown_content_value style=”background-color: #f9f9f9; padding: 5px 10px; “>Return an interger denoting the maximum X. </div>

Example Input
<div id=example_input_markdown_content_value style=”background-color: #f9f9f9; padding: 5px 10px; “>A=4

Example Output
<div id=example_output_markdown_content_value style=”background-color: #f9f9f9; padding: 5px 10px; “>2</div>

Example Explanation
<div id=example_explanation_markdown_content_value style=”background-color: #f9f9f9; padding: 5px 10px; “>We can distribute candies such that 2 persons gets candies of first type [2,2] and 2 persons gets candies of first type [3,2].

So the maximum X will be 2.

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Distribute candies on Interview Code Editor
Sign Up
to access hints and editorial solutions for Distribute candies


Click here to start solving coding interview questions