Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Maximum separation M people want to buy houses in a neighborhood. The neighborhood has N vacant houses that are built in a line for

Maximum separation M people want to buy houses in a neighborhood. The neighborhood has N vacant houses thatNote: Use this input format if you are testing against custom input or writing code in a language where we

Maximum separation M people want to buy houses in a neighborhood. The neighborhood has N vacant houses that are built in a line for sale. The position of these houses is position[i] with the distance being measured from the entrance gate. All the position[i]'s are distinct. These M people want to live as far away from each other as possible. The distance between two people is measured as position[i]- position[j]. Allot houses to these M people such that the minimum distance among all pairs of people is maximized. The output is the minimum maximized distance. Function description Complete the solve function. This function takes the following 3 parameters and returns the required answer: N: Represents the number of houses M: Represents the number of competitors position: Represents an array of locations of vacant houses 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 N denoting the number of houses. The second line contains M denoting the number of competitors. The third line contains an array position denoting the locations of the vacant houses. Output format Print a single integer indicating the minimum maximized distance. Constraints 2 N 105 2 M

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres the Python code that implements the above steps def so... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

Should the manager buy the new machine? Why or why not?

Answered: 1 week ago