b.sort()
found = False
best = 0
j = 0
for i in range(len(a)):
    while j < len(b) and a[i] * b[j] < lim:
        found = True
if a[i] * b[j] > best:
    best, n1, n2 = a[i] * b[j], a[i], b[j]
j += 1
return found and (best, n1, n2)
python - 2 списка и поиск максимального продукта из 2 списков