Problem p03290 (python)

Fixed submission:
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = count = 0; pro = 1

d,g=map(int,input().split());g//=100
D=collections.defaultdict(lambda: inf )
D[0]=0
for i in range(1,d+1):
    p,c=map(int,input().split());c//=100
    # for key, value in tuple(D.items()):
    #     print(D[key],p)
    #     D[key+i*p+c//100] = min(D[key+i*p+c//100], D[key]+p)
    S=D.copy()
    for key,value in S.items():
        for k in range(1,p):    
        # print(D[key+i])
            D[key+i*k] = min(D[key+i*k],S[key]+k)
        D[key+i*p+c] = min(D[key+i*p+c],S[key]+p)
ans=inf
for key,value in D.items():
    # print(key,value)
    if key>=g:
        ans=min(ans,value)
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = inf
count = 0; pro = 1

d, g = map(int, input().split())
g //= 100
dp=[[inf]*(10**5+1010) for i in range(11)]
dp[0][0]=0
for i in range(d):
    p,c=map(int,input().split());c//=100
    for j in range(10**5*2):
        if dp[i][j]!=inf:
            dp[i+1][j]=min(dp[i+1][j],dp[i][j])
            for k in range(1,p):
                dp[i+1][j+(i+1)*k]=min(dp[i+1][j+(i+1)*k],dp[i][j]+k)
            dp[i+1][j+(i+1)*p+c] = min(dp[i+1][j+(i+1)*p+c],dp[i][j]+p)
for i in range(g,10**5+10):
    ans=min(ans,dp[d][i])
print(ans)




# for i in range(1, d+1):
#     p, c = map(int, input().split())
#     c //= 100
#     # for key, value in tuple(D.items()):
#     #     print(D[key],p)
#     #     D[key+i*p+c//100] = min(D[key+i*p+c//100], D[key]+p)
#     S = D.copy()
#     for key, value in S.items():
#         for k in range(1, p):
#             # print(D[key+i])
#             D[key+i*k] = min(D[key+i*k], S[key]+k)
#         D[key+i*p+c] = min(D[key+i*p+c], S[key]+p)
# ans = inf
# for key, value in D.items():
#     # print(key,value)
#     if key >= g:
#         ans = min(ans, value)
# print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = inf
count = 0; pro = 1

d, g = map(int, input().split())
g //= 100
dp=[[inf]*(10**5+1010) for i in range(11)]
dp[0][0]=0
for i in range(d):
    p,c=map(int,input().split());c//=100
    for j in range(10**5+1010):
        if dp[i][j]!=inf:
            dp[i+1][j]=min(dp[i+1][j],dp[i][j])
            for k in range(1,p):
                dp[i+1][j+(i+1)*k]=min(dp[i+1][j+(i+1)*k],dp[i][j]+k)
            dp[i+1][j+(i+1)*p+c] = min(dp[i+1][j+(i+1)*p+c],dp[i][j]+p)
for i in range(g,10**5+10):
    ans=min(ans,dp[d][i])
print(ans)




# for i in range(1, d+1):
#     p, c = map(int, input().split())
#     c //= 100
#     # for key, value in tuple(D.items()):
#     #     print(D[key],p)
#     #     D[key+i*p+c//100] = min(D[key+i*p+c//100], D[key]+p)
#     S = D.copy()
#     for key, value in S.items():
#         for k in range(1, p):
#             # print(D[key+i])
#             D[key+i*k] = min(D[key+i*k], S[key]+k)
#         D[key+i*p+c] = min(D[key+i*p+c], S[key]+p)
# ans = inf
# for key, value in D.items():
#     # print(key,value)
#     if key >= g:
#         ans = min(ans, value)
# print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = inf
count = 0; pro = 1

d, g = map(int, input().split())
g //= 100
dp=[[inf]*11 for i in range(10**5+1010)]
dp[0][0]=0
for i in range(d):
    p,c=map(int,input().split());c//=100
    for j in range(10**5+1010):
        if dp[i][j]!=inf:
            dp[i+1][j]=min(dp[i+1][j],dp[i][j])
            for k in range(1,p):
                dp[i+1][j+(i+1)*k]=min(dp[i+1][j+(i+1)*k],dp[i][j]+k)
            dp[i+1][j+(i+1)*p+c] = min(dp[i+1][j+(i+1)*p+c],dp[i][j]+p)
for i in range(g,10**5+10):
    ans=min(ans,dp[10][i])
print(ans)




# for i in range(1, d+1):
#     p, c = map(int, input().split())
#     c //= 100
#     # for key, value in tuple(D.items()):
#     #     print(D[key],p)
#     #     D[key+i*p+c//100] = min(D[key+i*p+c//100], D[key]+p)
#     S = D.copy()
#     for key, value in S.items():
#         for k in range(1, p):
#             # print(D[key+i])
#             D[key+i*k] = min(D[key+i*k], S[key]+k)
#         D[key+i*p+c] = min(D[key+i*p+c], S[key]+p)
# ans = inf
# for key, value in D.items():
#     # print(key,value)
#     if key >= g:
#         ans = min(ans, value)
# print(ans)