class UserMainCode(object):
@classmethod
def mountainclimbing(cls, input1, input2):
if input1 < 3:
return 0
max_sum = 0
i = 1
while i < input1 - 1:
if input2[i - 1] < input2[i] and input2[i] > input2[i + 1]:
left = i - 1
right = i + 1
while left > 0 and input2[left - 1] < input2[left]:
left -= 1
while right < input1 - 1 and input2[right] > input2[right + 1]:
right += 1
current_sum = sum(input2[left:right + 1])
max_sum = max(max_sum, current_sum)
i = right
else:
i += 1
return max_sum
Y2xhc3MgVXNlck1haW5Db2RlKG9iamVjdCk6CiAgICBAY2xhc3NtZXRob2QKICAgIGRlZiBtb3VudGFpbmNsaW1iaW5nKGNscywgaW5wdXQxLCBpbnB1dDIpOgogICAgICAgIGlmIGlucHV0MSA8IDM6CiAgICAgICAgICAgIHJldHVybiAwCgogICAgICAgIG1heF9zdW0gPSAwCiAgICAgICAgaSA9IDEKICAgICAgICB3aGlsZSBpIDwgaW5wdXQxIC0gMToKICAgICAgICAgICAgaWYgaW5wdXQyW2kgLSAxXSA8IGlucHV0MltpXSBhbmQgaW5wdXQyW2ldID4gaW5wdXQyW2kgKyAxXToKICAgICAgICAgICAgICAgIGxlZnQgPSBpIC0gMQogICAgICAgICAgICAgICAgcmlnaHQgPSBpICsgMQoKICAgICAgICAgICAgICAgIHdoaWxlIGxlZnQgPiAwIGFuZCBpbnB1dDJbbGVmdCAtIDFdIDwgaW5wdXQyW2xlZnRdOgogICAgICAgICAgICAgICAgICAgIGxlZnQgLT0gMQoKICAgICAgICAgICAgICAgIHdoaWxlIHJpZ2h0IDwgaW5wdXQxIC0gMSBhbmQgaW5wdXQyW3JpZ2h0XSA+IGlucHV0MltyaWdodCArIDFdOgogICAgICAgICAgICAgICAgICAgIHJpZ2h0ICs9IDEKCiAgICAgICAgICAgICAgICBjdXJyZW50X3N1bSA9IHN1bShpbnB1dDJbbGVmdDpyaWdodCArIDFdKQogICAgICAgICAgICAgICAgbWF4X3N1bSA9IG1heChtYXhfc3VtLCBjdXJyZW50X3N1bSkKICAgICAgICAgICAgICAgIGkgPSByaWdodAogICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgaSArPSAxCgogICAgICAgIHJldHVybiBtYXhfc3Vt