Untitled
unknown
python
3 years ago
775 B
2
Indexable
Never
def solve(array): if len(array) == 1: return 0 if len(array) == 2: return 2 left = array[:len(array)//2] right = array[len(array)//2:] ans = max(solve(left),solve(right)) left_max = 0 left_index = 0 right_max = 0 right_index = 0 for i in range(len(left)-1,-1,-1): if max(left_max,int(left[i])) == int(left[i]): left_max = max(left_max,int(left[i])) left_index = i for i in range(0 , len(right)): if max(right_max,int(right[i])) == int(right[i]): right_max = max(right_max, int(right[i])) right_index = i ans = max(ans , right_index - left_index + 1 + len(left)) return ans def main(): l = input().split() print(solve(l)) main()