fork download
  1. class UserMainCode(object):
  2. @classmethod
  3. def mountainclimbing(cls, input1, input2):
  4. if input1 < 3:
  5. return 0
  6.  
  7. max_sum = 0
  8. i = 1
  9. while i < input1 - 1:
  10. if input2[i - 1] < input2[i] and input2[i] > input2[i + 1]:
  11. left = i - 1
  12. right = i + 1
  13.  
  14. while left > 0 and input2[left - 1] < input2[left]:
  15. left -= 1
  16.  
  17. while right < input1 - 1 and input2[right] > input2[right + 1]:
  18. right += 1
  19.  
  20. current_sum = sum(input2[left:right + 1])
  21. max_sum = max(max_sum, current_sum)
  22. i = right
  23. else:
  24. i += 1
  25.  
  26. return max_sum
Success #stdin #stdout 0.03s 9328KB
stdin
Standard input is empty
stdout
Standard output is empty