Problem p02805 (python)

Fixed submission:
N = int(input())
L = [[int(l) for l in input().split()] for _ in range(N)]

def dist(x, y, x0, y0):
    return ((x-x0)**2 + (y-y0)**2)**0.5

def f(x, y):
    res = 0
    for i in range(N):
        res = max(res, dist(L[i][0], L[i][1], x, y))
    return res

lx = -10**4
rx = 10**4
for _ in range(100):
    cx1 = (lx*2 + rx) / 3
    ly = -10**4
    ry = 10**4
    for _ in range(100):
        cy1 = (ly*2 + ry) / 3
        cy2 = (ly + ry*2) / 3
        if f(cx1, cy1) < f(cx1, cy2):
            ry = cy2
        else:
            ly = cy1
    y = (ly + ry) / 2
    
    cx2 = (lx + rx*2) / 3
    ly = -10**4
    ry = 10**4
    for _ in range(100):
        cy1 = (ly*2 + ry) / 3
        cy2 = (ly + ry*2) / 3
        if f(cx2, cy1) < f(cx2, cy2):
            ry = cy2
        else:
            ly = cy1

    if f(cx1, y) < f(cx2, ly):
        rx = cx2
        ans = f(cx1, y)
    else:
        lx = cx1
        ans = f(cx2, ly)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [[int(l) for l in input().split()] for _ in range(N)]

d = 0
for i in range(N-1):
    for j in range(i+1, N):
        tempd = ((L[i][0]-L[j][0])**2+(L[i][1]-L[j][1])**2)**0.5
        if d < tempd:
            d = tempd
            p = (i, j)

c = [(L[p[0]][0]+L[p[1]][0])/2, (L[p[0]][1]+L[p[1]][1])/2]
dc = 0
for i in range(N):
    if i == p[0] or i == p[1]:
        continue
    tempd = ((c[0]-L[i][0])**2+(c[1]-L[i][1])**2)**0.5
    if dc < tempd:
        dc = tempd
        pc = i

if dc <= d/2:
    ans = d/2
else:
    i = p[0]
    j = p[1]
    k = pc

    a = L[i][0]
    b = L[i][1]
    c = L[j][0]
    d = L[j][1]
    e = L[k][0]
    f = L[k][1]

    aa = a * a
    bb = b * b
    cc = c * c
    dd = d * d
    ee = e * e
    ff = f * f
    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))

    if c == a:
        px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a))
    else:
        px = (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))

    ans = math.hypot(px - a, py - b)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [[int(l) for l in input().split()] for _ in range(N)]

d = 0
for i in range(N-1):
    for j in range(i+1, N):
        tempd = ((L[i][0]-L[j][0])**2+(L[i][1]-L[j][1])**2)**0.5
        if d < tempd:
            d = tempd
            p = (i, j)

c = [(L[p[0]][0]+L[p[1]][0])/2, (L[p[0]][1]+L[p[1]][1])/2]
dc = 0
for i in range(N):
    if i == p[0] or i == p[1]:
        continue
    tempd = ((c[0]-L[i][0])**2+(c[1]-L[i][1])**2)**0.5
    if dc < tempd:
        dc = tempd
        pc = i

if dc <= d/2:
    ans = d/2
else:
    i = p[0]
    j = p[1]
    k = pc

    a = L[i][0]
    b = L[i][1]
    c = L[j][0]
    d = L[j][1]
    e = L[k][0]
    f = L[k][1]

    aa = a * a
    bb = b * b
    cc = c * c
    dd = d * d
    ee = e * e
    ff = f * f
    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))

    px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
        if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))

    ans = math.hypot(px - a, py - b)

print(ans)