Problem p03290 (python)

Fixed submission:
import math
D, G = map(int, input().split())

P = []
C = []
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

answer = sum(P)
for i in range(2**D):
    point = 0
    x = -1
    now_answer = 0
    for j in range(D):
        if i >> j & 1:
            point += P[j] * (j+1) * 100 + C[j]
            now_answer += P[j]
        else:
            x = j

    if G <= point:
        answer = min(now_answer, answer)
    else:
        n = math.ceil((G - point) / ((x+1) * 100))
        if n < P[x]:
            now_answer += n
            answer = min(now_answer, answer)

print(answer)

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())

P = []
C = []
C2 = []
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    c += p * (i+1) * 100
    C.append(c)
    C2.append(c/(p+1))

sort_C2 = sorted(C2, reverse=1)

num = 0
point = 0
question = [i for i in range(D-1, -1, -1)]


for i in range(D):
    x = C2.index(sort_C2[i])
    if C[x] <= G - point:
        num += P[x]
        point += C[x]
        question.remove(x)
    else:
        y = question[0]

        if C[x] < (y+1) * 100:
            continue

        n = -(-(G - point)) // ((y+1) * 100)
        if P[y] < n:
            num += P[y]
        else:
            num += n
        break

print(num)

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())

P = []
C = []
C2 = []
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    c += p * (i+1) * 100
    C.append(c)
    C2.append(c/(p+1))

sort_C2 = sorted(C2, reverse=1)

num = 0
point = 0
question = [i for i in range(D-1, -1, -1)]


for i in range(D):
    x = C2.index(sort_C2[i])
    if C[x] <= G - point:
        num += P[x]
        point += C[x]
        question.remove(x)
    else:
        y = question[0]

        if C2[x] < (y+1) * 100:
            continue

        n = -(-(G - point)) // ((y+1) * 100)
        if P[y] < n:
            num += P[y]
        else:
            num += n
        break

print(num)

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())

P = []
C = []
C2 = []
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    c += p * (i+1) * 100
    C.append(c)
    C2.append(c/(p+1))

sort_C2 = sorted(C2, reverse=1)

num = 0
point = 0
question = [i for i in range(D-1, -1, -1)]


for i in sort_C2:
    x = C2.index(i)
    if C[x] <= G - point:
        num += P[x]
        point += C[x]
        question.remove(x)
    else:
        y = question[0]
        n = -(-(G - point)) // ((y+1) * 100)
        if P[y] < n:
            num += P[y]
        else:
            num += n
        break

print(num)

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())

P = []
C = []
C2 = []
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    c += p * (i+1) * 100
    C.append(c)
    C2.append(c/(p+1))

sort_C2 = sorted(C2, reverse=1)

num = 0
point = 0
question = [i for i in range(D-1, -1, -1)]

for i in sort_C2:
    x = C2.index(i)
    if C[x] <= G - point:
        num += P[x]
        point += C[x]
        question.remove(x)
    else:
        y = question[0]
        num += -(-(G - point)) // ((y+1) * 100)
        break

print(num)