답안 #1055417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055417 2024-08-12T19:02:42 Z Hazard Binaria (CCO23_day1problem1) Python 3
0 / 25
9 ms 2908 KB
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))
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 2908 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 2908 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 2908 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 2908 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 2908 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 2908 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -