Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Challenge Specifics: The theme for this challenge is superheros and villains. The input to the program is a city skyline, with the heights of buildings

image text in transcribed

image text in transcribed

image text in transcribed

Challenge Specifics: The theme for this challenge is superheros and villains. The input to the program is a city skyline, with the heights of buildings (in floors or stories) along the skyline given in a sequence of values (h1, h2, ..., hn). Here is an example skyline: h 1 7 3 4 1 3 5 7 6 8 5 3 3 i 1 2 3 4 5 6 7 8 9 10 11 12 13 As program input, this would be given as a sequence of values (1,7,3,4,1,3,5,7,6,8,5,3,3). To provide this input to your program, it is given in the following format: on the first line is the number n, and then the n lines following that each have the values h1, h2, and so on. So for the example above, the input will given like this: 13 1 7 3 4 1 3 Your first task is to write a program for our superhero... ummm...... ArachnidMan. Yeah, that's it. (Similarity to any copyrighted superhero purely coincidental.) ArachnidMan charges up his superpowers from gravity, and gets the biggest boost by falling as far as possible (called the "maximum fall distance). He is traveling from left to right in our skyline, and can start from any position and jump to any position to the right. There's no limit on how far he can jump horizontally. Your task is to find the best position to jump from and to jump to in order to maximize his power gain (in other words, maximize the distance he falls). In the skyline above, his best solution is to jump from position 2 (height 7) to position 5 (height 1), falling 6 stories. To solve this problem, your program should find the best jumping-off position, and the position to jump to. One obvious solution is to try all possible pairs of i and j with 1 si

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. How were various roles filled?

Answered: 1 week ago