Question: SOLVE THIS PROBLEM IN C++ INPUT: 4 4 3 4 1 2 3 2 7 1 8 4 5 4 1 2 3 3 1

SOLVE THIS PROBLEM IN C++  SOLVE THIS PROBLEM IN C++ INPUT: 4 4 3 4 1

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

2 3 2 7 1 8 4 5 4 1 2 3

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!