Consider a billboard that consists of n vertical panels of width 1 and varying integer heights, hanged down and held by a horizontal roller from the top. The panel ¿has a height h For the objective of placing two banners, it is allowed to move each panel up by any integer length using the roller. Once the necessary moves are completed, you may place two banners completely inside of the panels. Based on the above description, what is the maximum total area that you can provide for the two posters? Input The first line of input contains one integer n (1

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Consider a billboard that consists of n vertical
panels of width 1 and varying integer heights,
hanged down and held by a horizontal roller
from the top. The panel i has a height h
For the objective of placing two banners, it is
allowed to move each panel up by any integer
length using the roller. Once the necessary
moves are completed, you may place two
banners completely inside of the panels.
Based on the above description, what is the
maximum total area that you can provide for the
two posters?
Output
Print a single integer- the maximum total area the two posters can cover together.
Example 1:
6
Input:
Output: 18
Input
The first line of input contains one integer n (1<n<1000)- the number of vertical panels.
The second line of input contains ʼn integers hh....h (1shs1000)- the heights of the n vertical
panels.
223545
Note
In this sample test, we can choose two
areas:12 and 6 as illustrated in the image.
1 2 ...
Example 2:
5
Input:
Output: 17
45343
6
3
12
hi
- Design a brute-force algorithm to solve this problem using a (Pseudocode) and find its
complexity.
- Implement your brute-force algorithm using Python and invent an example of 7 vertical
panels with different heights to demonstrate your solution
Can a more efficient solution be designed? If yes, demonstrate it using Pseudocode
and analyze its complexity
Transcribed Image Text:Consider a billboard that consists of n vertical panels of width 1 and varying integer heights, hanged down and held by a horizontal roller from the top. The panel i has a height h For the objective of placing two banners, it is allowed to move each panel up by any integer length using the roller. Once the necessary moves are completed, you may place two banners completely inside of the panels. Based on the above description, what is the maximum total area that you can provide for the two posters? Output Print a single integer- the maximum total area the two posters can cover together. Example 1: 6 Input: Output: 18 Input The first line of input contains one integer n (1<n<1000)- the number of vertical panels. The second line of input contains ʼn integers hh....h (1shs1000)- the heights of the n vertical panels. 223545 Note In this sample test, we can choose two areas:12 and 6 as illustrated in the image. 1 2 ... Example 2: 5 Input: Output: 17 45343 6 3 12 hi - Design a brute-force algorithm to solve this problem using a (Pseudocode) and find its complexity. - Implement your brute-force algorithm using Python and invent an example of 7 vertical panels with different heights to demonstrate your solution Can a more efficient solution be designed? If yes, demonstrate it using Pseudocode and analyze its complexity
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education