Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 2 - NumFalls (10 points) Arachnid Man has a new sidekick, BlackFeline, who also has superpowers that charge up by falling, but in a
Problem 2 - NumFalls (10 points) Arachnid Man has a new sidekick, BlackFeline, who also has superpowers that charge up by falling, but in a slightly different way. BlackFeline makes a sequence of falling jumps, and gets one unit of "superpower charge" for each jump. It doesn't matter how far the fall is, there's one unit of charge for any fall. Every jump does have to go from left to right and it has to be a fall BlackFeline can never jump to the left or to a position at the same level or higher. Consider the same skyline as last time: 4 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 If BlackFeline starts at position 2 (height 7), jumps to position 3 (height 3), and then to position 5 (height 1), she gets 2 units of superpower charge. However, that's not the best choice! She can start at position 2, jump to position 9, then to position 11, and finally to position 12. She doesn't fall as far as the first scenario, but since there are 3 falls instead of 2, she gets 3 units of superpower charge from this possibility. Your challenge is to write a program that reads a skyline input as described in the previous programming challenge, and calculate the largest possible superpower charge that BlackFeline can gain. The skyline can have up to 10,000 entries, and your solution must run in under 15 seconds. Output should consist of just the maximum charge, an integer on a single line, so with the sample scenario Problem 2 - NumFalls (10 points) Arachnid Man has a new sidekick, BlackFeline, who also has superpowers that charge up by falling, but in a slightly different way. BlackFeline makes a sequence of falling jumps, and gets one unit of "superpower charge" for each jump. It doesn't matter how far the fall is, there's one unit of charge for any fall. Every jump does have to go from left to right and it has to be a fall BlackFeline can never jump to the left or to a position at the same level or higher. Consider the same skyline as last time: 4 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 If BlackFeline starts at position 2 (height 7), jumps to position 3 (height 3), and then to position 5 (height 1), she gets 2 units of superpower charge. However, that's not the best choice! She can start at position 2, jump to position 9, then to position 11, and finally to position 12. She doesn't fall as far as the first scenario, but since there are 3 falls instead of 2, she gets 3 units of superpower charge from this possibility. Your challenge is to write a program that reads a skyline input as described in the previous programming challenge, and calculate the largest possible superpower charge that BlackFeline can gain. The skyline can have up to 10,000 entries, and your solution must run in under 15 seconds. Output should consist of just the maximum charge, an integer on a single line, so with the sample scenario
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started