def count_strings(N, K, sms):
MOD = 10**6 + 3
dp = [[0]*(K+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
for j in range(K+1):
if i < K:
dp[i+1][j+1] += dp[i][j]
dp[i+1][j] += dp[i][j]
else:
target = sms[i-K+1]
if j >= target:
dp[i+1][j-target+1] += dp[i][j]
dp[i+1][j] += dp[i][j]
dp[i+1][j+1] %= MOD
dp[i+1][j] %= MOD
ans = 0
for i in range(K+1):
ans += dp[N][i]
ans %= MOD
return ans
N, K = map(int, input().split())
sms = list(map(int, input().split()))
print(count_strings(N, K, sms))
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
2908 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
2908 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
2908 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
2908 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
2908 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
2908 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |