Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

INPUT: 4 4 3 4 1 2 3 2 7 1 8 4 5 4 1 2 3 3 1 5 3 1 OUTPUT: 2

image text in transcribed

INPUT: 4 4 3 4 1 2 3 2 7 1 8 4 5 4 1 2 3 3 1 5 3 1

OUTPUT: 2 1 -1 -1 image text in transcribed

SOLVE THIS PROBLEM IN C++

After reaching your destination, you want to build a new colony on the new planet. Since this planet has many mountains and the colony must be built on a flat surface you decided to flatten the mountains using boulders (you are still dreaming so this makes sense to you). . . You are given an array h1, h2, ..., hn, where h is the height of the i-th mountain, and k the number of boulders you have. You will start throwing boulders from the top of the first mountain one by one and they will roll as follows (let's assume that the height of the current mountain is hi): if hi > hit1, the boulder will roll to the next mountain; if h; h2 it rolls to i = 2 and stops there because h2 h2 the boulder rolls to i = 2; since h2> h3 the boulder rolls to i = 3 and stops there because hz h2 it rolls to i = 2 and stops there because h2

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

More Books

Students also viewed these Databases questions

Question

2. Show the trainees how to do it without saying anything.

Answered: 1 week ago