Maximum possible value of array elements that can be made based on given capacity conditions | Function to find the maximum element after shifting operations in arr [ ] ; Stores the sum of array element ; Stores the maximum element in cap [ ] ; Iterate to find maximum element ; Return the resultant maximum value ; Driver Code
def maxShiftArrayValue ( arr , cap , N ) : NEW_LINE INDENT sumVals = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT sumVals += arr [ i ] NEW_LINE DEDENT maxCapacity = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT maxCapacity = max ( cap [ i ] , maxCapacity ) NEW_LINE DEDENT return min ( maxCapacity , sumVals ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 2 , 3 ] NEW_LINE cap = [ 5 , 6 ] NEW_LINE N = len ( arr ) NEW_LINE print ( maxShiftArrayValue ( arr , cap , N ) ) NEW_LINE DEDENT