Problem p02787 (python)

Fixed submission:
H,N =map(int,input().split()) 
dp = [[0] * (10001) for i in range(1001)]
A,B = map(int,input().split()) 
for j in range(1, H+1):
    dp[0][j] = B * int((j+A-1)/A)

for i in range(1,N):
    A,B = map(int,input().split())
    for j in range(1, A+1):
        dp[i][j] = min(dp[i-1][j], B)
    for j in range(A+1, H+1):
        dp[i][j] = min(dp[i-1][j], dp[i][j-A] + B)

print(dp[N-1][H])

Buggy submission (verdict: Runtime Error):
H,N =map(int,input().split()) 
dp = [[0] * (H+1) for i in range(N)]
A,B = map(int,input().split()) 
for j in range(1, H+1):
    dp[0][j] = B * int((j+A-1)/A)

for i in range(1,N):
    A,B = map(int,input().split())
    for j in range(1, A+1):
        dp[i][j] = min(dp[i-1][j], B)
    for j in range(A+1, H+1):
        dp[i][j] = min(dp[i-1][j], dp[i][j-A] + B)

print(dp[N-1][H])

Buggy submission (verdict: Runtime Error):
H,N =map(int,input().split()) 
dp = [[0] * (H+1) for i in range(N)]
A,B = splitintinput()
for j in range(1, H+1):
    dp[0][j] = B * int((j+A-1)/A)

for i in range(1,N):
    A,B = map(int,input().split())
    for j in range(1, A+1):
        dp[i][j] = min(dp[i-1][j], B)
    for j in range(A+1, H+1):
        dp[i][j] = min(dp[i-1][j], dp[i][j-A] + B)

print(dp[N-1][H])

Buggy submission (verdict: Runtime Error):

def splitintinput():
    return map(int,input().split())

H,N = splitintinput()
dp = [[0] * (H+1) for i in range(N)]
A,B = splitintinput()
for j in range(1, H+1):
    dp[0][j] = B * int((j+A-1)/A)

for i in range(1,N):
    A,B = splitintinput()
    for j in range(1, A+1):
        dp[i][j] = min(dp[i-1][j], B)
    for j in range(A+1, H+1):
        dp[i][j] = min(dp[i-1][j], dp[i][j-A] + B)

print(dp[N-1][H])

Buggy submission (verdict: Runtime Error):
import math

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

H,N = splitintinput()
dp = [[0] * (H+1) for i in range(N)]
A,B = splitintinput()
for j in range(1, H+1):
    dp[0][j] = B * math.ceil(j/A)

for i in range(1,N):
    A,B = splitintinput()
    for j in range(1, A+1):
        dp[i][j] = min(dp[i-1][j], B)
    for j in range(A+1, H+1):
        dp[i][j] = min(dp[i-1][j], dp[i][j-A] + B)

print(dp[N-1][H])

Buggy submission (verdict: Runtime Error):
import math

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

H,N = splitintinput()
dp = [[0] * (H+1) for i in range(N)]
A,B = splitintinput()
for j in range(1, H+1):
    dp[0][j] = B * math.ceil(j/A)

for i in range(1,N):
    A,B = splitintinput()
    for j in range(1, A+1):
        dp[i][j] = min(dp[i-1][j], B)
    for j in range(A+1, H+1):
        dp[i][j] = min(dp[i-1][j], dp[ij-A] + B)

print(dp[N-1][H])

Buggy submission (verdict: Runtime Error):

def splitintinput():
    return map(int,input().split())

H,N = splitintinput()
dp = [[0] * (H+1) for i in range(N)]
A,B = splitintinput()
for j in range(1, H+1):
    dp[0][j] = B * math.ceil(j/A)

for i in range(1,N):
    A,B = splitintinput()
    for j in range(1, A+1):
        dp[i][j] = min(dp[i-1][j], B)
    for j in range(A+1, H+1):
        dp[i][j] = min(dp[i-1][j], dp[ij-A] + B)

print(dp[N-1][H])