Problem p04013 (python)

Fixed submission:
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

dp=[[0 for i in range(a*n+1)] for j in range(n+1)]
dp[0][0]=1
ans=0
f=0

for k in range(1,n+1):
  kx=x[k-1]
  f+=kx
  for i in range(k,0,-1):
    for j in range(kx,a*n+1):
      dp[i][j] += dp[i-1][j-kx]
      if j > f:
        break
      
for i in range(1,n+1):
  ans+=dp[i][a*i]

print(ans)

Buggy submission (verdict: Runtime Error):
 n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

dp=[[0 for i in range(a*n+1)] for j in range(n+1)]
dp[0][0]=1
ans=0
f=0

for k in range(1,n+1):
  kx=x[k-1]
  f+=kx
  for i in range(k,0,-1):
    for j in range(kx,a*n+1):
      dp[i][j] += dp[i-1][j-kx]
      if j > f:
        break
      
for i in range(1,n+1):
  ans+=dp[i][a*i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
sx=sum(x)
dp= np.zeros((n+1,sx+1),dtype='int32')
#dp=[[0]*(n*a+1)]*(n+1)
dp[0][0]=1
ans=0
f=0
for k in range(1,n+1):
  kx=x[k-1]
  f+=kx
  for i in range(k,0,-1):
    for j in range(kx,sx+1):
      dp[i][j] += dp[i-1][j-kx]
      if j > f:
        break
      
for i in range(1,n+1):
  if i >=sx:
    break
  ans+=dp[i][a*i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

dp= np.zeros((n+1,n*a+1),dtype=int)
dp[0][0]=1
ans=0

f=0
for k in range(1,n+1):
  f+=x[k-1]
  for i in range(k,-1,-1):
    for j in range(0, f + 1):
      if j>=x[k-1] and i>=1:
        dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]]
      else:
        dp[i][j]= dp[i][j] 
      
for i in range(1,n+1):
  ans+=dp[i][a*i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
sx=sum(x)
dp= np.zeros((n+1,n*a+1),dtype=int)
dp[0][0]=1
ans=0

f=0
for k in range(1,n+1):
  f+=k
  for i in range(k,-1,-1):
    for j in range(0, f + 1):
      if j>=x[k-1] and i>=1:
        dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]]
      else:
        dp[i][j]= dp[i][j] 
      
for i in range(1,n+1):
  ans+=dp[i][a*i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
sx=sum(x)
dp= np.zeros((n+1,n*a+1),dtype=int)
dp[0][0]=1
ans=0

for k in range(1,n+1):
  for i in range(k,-1,-1):
    for j in range(0, sx * n + 1):
      if j>=x[k-1] and i>=1:
        dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]]
      else:
        dp[i][j]= dp[i][j] 
      
for i in range(1,n+1):
  ans+=dp[i][a*i]

print(ans)

Buggy submission (verdict: Runtime Error):
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

dp= np.zeros((n+1,n+1,n*a+1),dtype=int)
dp[0][0][0]=1
ans=0

for k in range(1,n+1):
  for i in range(0,k+1):
    for j in range(0,a * i+1):
      if j>=x[k-1] and i>=1:
        dp[k][i][j]= dp[k-1][i][j] + dp[k-1][i-1][j-x[k-1]]
      else:
        dp[k][i][j]= dp[k-1][i][j] 
      
for i in range(1,n+1):
  ans+=dp[n][i][a*i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

dp= np.zeros((n+1,s*n+1),dtype=int)
dp[0][0]=1
ans=0

for k in range(1,n+1):
  for i in range(0,k+1):
    for j in range(0,s*n+1):
      if j>=x[k-1] and i>=1:
        dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]]
      else:
        dp[i][j]= dp[i][j] 
      
for i in range(1,n+1):
  ans+=dp[i][a*i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
xs=sum(x)
dp= np.zeros((n+1,xs*n+1),dtype=int)
dp[0][0][0]=1
ans=0

for k in range(1,n+1):
  for i in range(0,k+1):
    for j in range(0,xs*n+1):
      if j>=x[k-1] and i>=1:
        dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]]
      else:
        dp[i][j]= dp[i][j] 
      
for i in range(1,n+1):
  ans+=dp[i][a*i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
xs=sum(x)
dp= np.zeros((n+1,n+1,xs*n+1),dtype=int)
dp[0][0][0]=1
ans=0

for k in range(1,n+1):
  for i in range(0,k+1):
    for j in range(0,xs*n+1):
      if j>=x[k-1] and i>=1:
        dp[k][i][j]= dp[k-1][i][j] + dp[k-1][i-1][j-x[k-1]]
      else:
        dp[k][i][j]= dp[k-1][i][j] 
      
for i in range(1,n+1):
  ans+=dp[n][i][a*i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
xs=sum(x)
dp= np.zeros((n+1,n+1,n*a+1),dtype=int)
dp[0][0][0]=1
ans=0

for k in range(1,n+1):
  for i in range(0,k+1):
    for j in range(0,xs*n+1):
      if j>=x[k-1] and i>=1:
        dp[k][i][j]= dp[k-1][i][j] + dp[k-1][i-1][j-x[k-1]]
      else:
        dp[k][i][j]= dp[k-1][i][j] 
      
for i in range(1,n+1):
  ans+=dp[n][i][a*i]

print(ans)