Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Metro Land is a country located on a 2D Plane. They are having asummer festival for everyone in the country and would like tominimize the

 

image

Metro Land is a country located on a 2D Plane. They are having asummer festival for everyone in the country and would like tominimize the overall cost of travel for their citizens. Costs oftravel are calculated as follows:

1) A city is located at coordinates(x,y)

2) The festival is located at coordinates(a,b)

3) cost of travel from a city to the festival = |x - a| + |y -b| per person

The festival can be held at any location in Metro-land. Find theoptimal location for the festival, defined as the location with theminimal total travel cost assuming all people attend. Determine thetotal cost of travel for all citizens to go to the festival at thatlocation.

Example: numsPeople:[1, 2], x = [1, 3], y = [1, 3]. The lowesttotal cost to travel is if the event is held at grid position(3 ,3) at cost of 4.

See this link has more details:https://codingee.com/metro-land-hacker-rank/

Metro Land is a country located on a 2D plane. They are having a summer festival for everyone in the country and would like to minimize the overall cost of travel for their citizens. Costs of travel are calculated as follows: A city is located at coordinates (x, y). The festival is located at coordinates (a, b). Cost of travel from a city to the festival = |x-a| + |y-bl per person. The festival can be held at any location in Metro Land. Find the optimal location for the festival, defined as the location with the minimal total travel cost assuming all people attend. Determine the total cost of travel for all citizens to go to the festival at that location. Example numPeople = [1, 2] x = [1, 3] y = [1,3] There is 1 person in City 0 located at (x[0], y[0]) = (1, 1) and there are 2 people in City 1 at (x[1], y[1]) =(3, 3). If the location for the festival is at (2, 2):

Step by Step Solution

3.53 Rating (170 Votes )

There are 3 Steps involved in it

Step: 1

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

Fundamentals of Cost Accounting

Authors: William Lanen, Shannon Anderson, Michael Maher

3rd Edition

9780078025525, 9780077517359, 77517350, 978-0077398194

More Books

Students also viewed these Programming questions

Question

How do we do subnetting in IPv6?Explain with a suitable example.

Answered: 1 week ago

Question

Explain the guideline for job description.

Answered: 1 week ago

Question

What is job description ? State the uses of job description.

Answered: 1 week ago

Question

What are the objectives of job evaluation ?

Answered: 1 week ago

Question

Write a note on job design.

Answered: 1 week ago