Minimize product of two scores possible by at most M reductions | Utility function to find the minimum product of R1 and R2 possible ; Reaching to its limit ; If M is remaining ; Function to find the minimum product of R1 and R2 ; Case 1 - R1 reduces first ; case 2 - R2 reduces first ; Driver Code ; Given Input ; Function Call
def minProductUtil ( R1 , B1 , R2 , B2 , M ) : NEW_LINE INDENT x = min ( R1 - B1 , M ) NEW_LINE M -= x NEW_LINE R1 -= x NEW_LINE if M > 0 : NEW_LINE INDENT y = min ( R2 - B2 , M ) NEW_LINE M -= y NEW_LINE R2 -= y NEW_LINE DEDENT return R1 * R2 NEW_LINE DEDENT def minProduct ( R1 , B1 , R2 , B2 , M ) : NEW_LINE INDENT res1 = minProductUtil ( R1 , B1 , R2 , B2 , M ) NEW_LINE res2 = minProductUtil ( R2 , B2 , R1 , B1 , M ) NEW_LINE return min ( res1 , res2 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT R1 = 21 ; B1 = 10 ; R2 = 13 ; B2 = 11 ; M = 3 NEW_LINE print ( minProduct ( R1 , B1 , R2 , B2 , M ) ) NEW_LINE DEDENT