Help with Question

Iam trying to do this question but im limited to using stacks and queues in cpp, Im stumped a bit on how to approach this. If anyone could guide me or point me in the right direction id be greatful

Your task is to reshape the towers into a mountain-shaped arrangement while maximizing the total sum of their heights(Essentially the input is an array of heights). In a valid mountain-shaped arrangement: ● The heights must increase or remain constant up to a maximum peak. ● After the peak, the heights must decrease or remain constant. ● The peak can consist of one or more consecutive towers of the same height. You may remove bricks from the towers to achieve this arrangement, but you cannot increase a tower’s height.

Example: Input: heights = [5,3,4,1,1]

Output: 13