Panda and pandaland

3.9

18 votes
Easy
Problem

This time panda is on vacations in pandaland . He is amazed by huge buildings in pandaland . Suddenly he met his friend Mike.Mike to test his programming skills gave him a question : Given an array A of length N consisting of 'height of buildings'(buildings are rectangles of equal width),find the maximum possible area of rectangle that can be generated by joining contiguous buildings.

enter image description here

INPUT:
First line of input contains T the number of test cases,Each test case contains two lines,first line of each input contains N the number buildings and second line of each test case contains an array of length N consisting of height of buildings.

OUTPUT:
Output the answer according to question.

CONSTRAINTS:
1<=T<=10
1<=N<=10^5
1<=A[i]<=10^5

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?