CCF Python题解(100分)201312-3 最大的矩形

CCF Python题解(100分)201312-3 最大的矩形

n = int(input())
data = list(map(int, input().split()))


def square(index):
    count = 1
    for i in range(index+1,len(data)):
        if data[i] >= data[index]:
            count += 1
        else:
            break
    for i in range(index-1,-1,-1):
        if data[i] >= data[index]:
            count += 1
        else:
            break
    return count * data[index]


squares = [square(i) for i in range(len(data))]
print(max(squares))

猜你喜欢

转载自blog.csdn.net/qq_39577481/article/details/84027187
今日推荐