Problem p04011 (python)

Fixed submission:
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)

Buggy submission (verdict: Runtime Error):
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*(50*n+1) for _ in range(n+1)] for _ in range(n+1)]
for i in range(n+1):
    for j in range(n+1):
        for k in range(50*n+1):
            if i == 0 and j == 0 and k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, n+1):
    ans += dp[n][j][a*j]
print(ans)

Buggy submission (verdict: Runtime Error):
N, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)]
for i in range(N+1):
    for j in range(N+1):
        for k in range(50*N+1):
            if i == 0 and j == 0 and k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, N+1):
    ans += dp[N][j][a*j]
print(ans)

Buggy submission (verdict: Runtime Error):
N, a = map(int, input().split())
*x, = (map(int, input().split()))
dp = [[[0]*(50*N+1) for _ in range(N+1)] for i in range(N+1)]
for i in range(N+1):
    for j in range(N+1):
        for k in range(50*N+1):
            if i == j == k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, N+1):
    ans += dp[N][j][a*j]
print(ans)

Buggy submission (verdict: Runtime Error):
N, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*(50*N+1) for _ in range(N+1)] for i in range(N+1)]
for i in range(N+1):
    for j in range(N+1):
        for k in range(50*N+1):
            if i == j == k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, N+1):
    ans += dp[N][j][a*j]
print(ans)

Buggy submission (verdict: Runtime Error):
N, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)]
for i in range(N+1):
    for j in range(N+1):
        for k in range(50*N+1):
            if i == j == k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, N+1):
    ans += dp[N][j][a*j]
print(ans)

Buggy submission (verdict: Runtime Error):
N, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)]
for i in range(N+1):
    for j in range(N+1):
        for k in range(50*N+1):
            if i == j == k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, N+1):
    ans += dp[N][j][a*j]
print(ans)