Find the required pair
for i in range ( 0 , p ) : NEW_LINE INDENT for j in range ( i + 1 , p ) : NEW_LINE INDENT if ( arr [ i ] + arr [ j ] < k and arr [ i ] + arr [ j ] > maxsum ) : NEW_LINE INDENT maxsum = arr [ i ] + arr [ j ] NEW_LINE a = arr [ i ] NEW_LINE b = arr [ j ] NEW_LINE DEDENT DEDENT DEDENT