Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Was a challenge problem in our Java class. A full solution w/ proper variable names would be best for understanding everything but a logic based

image text in transcribed

Was a challenge problem in our Java class. A full solution w/ proper variable names would be best for understanding everything but a logic based one that goes through what would need to be done also works

With the hottest recorded summer ever at Farmer John's farm, he needs a way to cool down his cows. Thus, he decides to invest in some air conditioners. Farmer John's N cows (1N20) live in a barn that contains a sequence of stalls in a row, numbered 1100. Cow i occupies a range of these stalls, starting from stall si and ending with stall ti. The ranges of stalls occupied by different cows are all disjoint from each-other. Cows have different cooling requirements. Cow i must be cooled by an amount ci, meaning every stall occupied by cow i must have its temperature reduced by at least ci units. The barn contains M air conditioners, labeled 1M(1M10). The i th air conditioner costs mi units of money to operate ( 1mi1000) and cools the range of stalls starting from stall ai and ending with stall bi. If running, the i th air conditioner reduces the temperature of all the stalls in this range by pi(1pi106). Ranges of stalls covered by air conditioners may potentially overlap. Running a farm is no easy business, so FJ has a tight budget. Please determine the minimum amount of money he needs to spend to keep all of his cows comfortable. It is guaranteed that if FJ uses all of his conditioners, then all cows will be comfortable. INPUT FORMAT (input arrives from the terminal / stdin): The first line of input contains N and M. The next N lines describe cows. The i th of these lines contains si,ti, and ci. The next M lines describe air conditioners. The i th of these lines contains ai,bi,pi, and mi. For every input other than the sample, you can assume that M=10. OUTPUT FORMAT (print output to the terminal / stdout): Output a single integer telling the minimum amount of money FJ needs to spend to operate enough air conditioners to satisfy all his cows (with the conditions listed above). SAMPLE INPUT: 217211645996292322413825 SAMPLE OUTPUT: 10 One possible solution that results in the least amount of money spent is to select those that cool the intervals [2,9], [1,2], and [6,9], for a cost of 3+2+5=10

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

Real Time Database And Information Systems Research Advances

Authors: Azer Bestavros ,Victor Fay-Wolfe

1st Edition

1461377803, 978-1461377801

More Books

Students also viewed these Databases questions

Question

Describe the sense of touch.

Answered: 1 week ago

Question

Types of Interpersonal Relationships?

Answered: 1 week ago

Question

Self-Disclosure and Interpersonal Relationships?

Answered: 1 week ago