Problem p03163 (python)

Fixed submission:
N, W = [int(i) for i in input().split()]
weight, value = [], []

for i in range(N):
    w, v = [int(i) for i in input().split()]
    weight.append(w); value.append(v);
weight.append(0)
value.append(0)

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if (j-weight[i] >= 0):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = [int(i) for i in input().split()]
weight, value = [0]*110000, [0]*110000

for i in range(N):
    w, v = [int(i) for i in input().split()]
    weight[i] = w; value[i] = v;

dp = [[0 for _ in range(110)] for _ in range(100100)]

for i in range(N):
    for j in range(W+1):
        if (j-weight[i] >= 0):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = [int(i) for i in input().split()]
weight, value = [0]*110, [0]*110

for i in range(N):
    w, v = [int(i) for i in input().split()]
    weight[i] = w; value[i] = v;

dp = [[0 for _ in range(110)] for _ in range(100100)]

for i in range(N):
    for j in range(W+1):
        if (j-weight[i] >= 0):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = [int(i) for i in input().split()]
weight, value = [0]*110, [0]*110

for i in range(N):
    w, v = [int(i) for i in input().split()]
    weight[i] = w; value[i] = v;

dp = [[0 for _ in range(110)] for _ in range(100100)]

for i in range(N):
    for j in range(W+1):
        if (j-weight[i] >= 0):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = [int(i) for i in input().split()]
weight, value = [0]*110, [0]*110

for i in range(N):
    w, v = [int(i) for i in input().split()]
    weight[i] = w; value[i] = v;

dp = [[0 for _ in range(110)] for _ in range(100100)]

for i in range(N):
    for j in range(W+1):
        if (j-weight[i] >= 0):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = [int(i) for i in input().split()]
weight, value = [], []

for i in range(N):
    w, v = [int(i) for i in input().split()]
    weight.append(w); value.append(v);
weight += [0]*100
value += [0]*100

dp = [[0 for _ in range(110)] for _ in range(100100)]

for i in range(N):
    for j in range(W+1):
        if (j-weight[i] >= 0):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = [int(i) for i in input().split()]
weight, value = [], []

for i in range(N):
    w, v = [int(i) for i in input().split()]
    weight.append(w); value.append(v);

dp = [[0 for _ in range(110)] for _ in range(100100)]

for i in range(N):
    for j in range(W+1):
        if (j-weight[i] >= 0):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])