Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2 . The gold mining company Gold 3 3 6 wants to buy a lot of land. It has a list of available lots

Problem 2. The gold mining company Gold336 wants to buy a lot of land. It has a list of available
lots LOTS. Each lot i is an axis-parallel rectangle with coordinates LOTS [i].x1,LOTS[i].x2,LOTS[i]*y1,
LOTS [i].y2. The cost of the lot is LOTS i.cost. The company also has a list of gold mines GOLDMINES.
Mine j has coordinates goldMines [j].x and GOLDMines [j].y and value GoldMines j.value. The
total revenue that Gold336 can get from lot i equals the sum of values of gold mines located on
the property (boundaries are included). The profit from the lot equals the revenue from that lot
minus its cost. Your goal is to design an algorithm that finds the best lot. Lots do not overlap, i.e.
they are disjoint rectangles. Lots are non-degenerate rectangles, meaning lots [i].y1<[i].y22*1052*109[i].x1 and
lots [i].y1< lots [i].y2. There might be multiple gold mines in the same location.
Please, design an algorithm for this problem. Implement the following function.
long long int FindBestLot(const vector& lots,
const vector& goldMines)
The function should return the profit of the most profitable lot. The parameters are as follows: lots
is the list of lots; goldMines is the list of gold mines.
Submission The instructions are similar to the previous homeworks. Your program must pass
each test inno more than 1 second. You can assume that the number of lots and the number of
gold mines isat most 2*105, and at least one lot exists. All other numbers are between 0 and 2*109
.#include
using std::vector;
struct Lot {
int x1, y1;
int x2, y2;
int cost;
Lot(int x1, int y1, int x2, int y2, int cost): x1(x1), y1(y1), x2(x2), y2(y2), cost(cost){}
};
struct GoldMine {
int x, y;
int value;
GoldMine(int x, int y, int value): x(x), y(y), value(value){}
};
long long int FindBestLot(const vector& lots, const vector& goldMines){
}

Step by Step Solution

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

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

c. What are the job responsibilities?

Answered: 1 week ago

Question

Learn about the labor context in Canada and Quebec.

Answered: 1 week ago