Problem p03161 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-k),i))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**10]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[j]+min(h[j]-h[i]) for j in range(max(0,i-k),i))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**10]*n
dp[0]=0
for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i]=min(dp[j]+min(h[j]-h[i]))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**10]*n
dp[0]=0
for i in range(1,n):
    if i>=k:
        for j in range(i-k,i):
            dp[i]=dp[j]+min(h[j]-h[i])
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**10]*n
dp[0]=0
for i in range(1,n):
    for j in range(i-k,i):
        dp[i]=dp[j]+min(h[j]-h[i])
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**10]*n
dp[0]=0
for i in range(1,n):
    for j in range(1,n):
        dp[i]=dp[j]+min(h[j]-h[i])
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[j]+abs(h[j]-h[j+k]) for j in range(max(0,n-k),i))
    print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[i-j]+abs(h[i-j]-h[i]) for j in range(1,k))
    print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(2,n):
    dp[i]=min(dp[i-j]+abs(h[i-j]-h[i]) for j in range(1,k))
    print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(2,n):
        dp[i]=min(dp[i-j]+abs(h[i-j]-h[i]) for j in range(1,k))
        print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(2,n):
    for j in range(1,k):
        dp[i]=min(dp[i-j]+abs(h[i-j]-h[i]))
        print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(2,n):
    for j in range(1,k):
        dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
        print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(2,n):
    for j in range(1,k):
        dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
        pront(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(2,n):
    for j in range(1,k):
        dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
        pront(dp[n-1])