Problem: There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.  However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps? Find the count modulo 1\ 000\ 000\ 007.

Submission attempts (in order):
import numpy as np
N, M = map(int, input().split())
if M == 1:
    A = int(input())
else:
    A = np.array([int(input()) for _ in range(M)], dtype = int)

MOD= 1000000007
dp = np.zeros(N, dtype = int)
dp[A - 1] = -1
if dp[0] == -1 and dp[1] == -1:
    pass
elif dp[0] == -1:
    dp[1] = 1
elif dp[1] == -1:
    dp[0] = 1
else:
    dp[0] = 1; dp[1] = 2;


# if N >= 3:
#     for n in range(2, N):

#             dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])


import numpy as np
N, M = map(int, input().split())
if M == 1:
    A = int(input())
else:
    A = np.array([int(input()) for _ in range(M)], dtype = int)

MOD= 1000000007
dp = np.zeros(N, dtype = int)
dp[A - 1] = - 1
if dp[0] == -1 and dp[1] == -1:
    pass
elif dp[0] == -1:
    dp[1] = 1
elif dp[1] == -1:
    dp[0] = 1
else:
    dp[0] = 1; dp[1] = 2;


# if N >= 3:
#     for n in range(2, N):

#             dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])


import numpy as np
N, M = map(int, input().split())
if M == 1:
    A = int(input())
else:
    A = np.array([int(input()) for _ in range(M)], dtype = int)

MOD= 1000000007
dp = np.zeros(N, dtype = int)
dp[A - 1] = -1
if dp[0] == -1 and dp[1] == -1:
    pass
elif dp[0] == -1:
    dp[1] = 1
elif dp[1] == -1:
    dp[0] = 1
# else:
#     dp[0] = 1
#     dp[1] = 2


# if N >= 3:
#     for n in range(2, N):

#             dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])


import numpy as np
N, M = map(int, input().split())
if M == 1:
    A = int(input())
else:
    A = np.array([int(input()) for _ in range(M)], dtype = int)
l_a = len(A)

MOD= 1000000007
dp = np.zeros(N, dtype = int)
dp[A - 1] = - 1
if dp[0] == -1 and dp[1] == -1:
    pass
elif dp[0] == -1:
    dp[1] = 1
elif dp[1] == -1:
    dp[0] = 1
else:
    dp[0] = 1; dp[1] = 2;


if N >= 3:
    for n in range(2, N):
        if dp[n] != -1:
            dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])


import numpy as np
N, M = map(int, input().split())
if M == 1:
    A = int(input())
else:
    A = np.array([int(input()) for _ in range(M)], dtype = int)

MOD= 1000000007
dp = np.zeros(N, dtype = int)
dp[A - 1] = - 1
if dp[0] == -1 and dp[1] == -1:
    pass
elif dp[0] == -1:
    dp[1] = 1

#     dp[0] = 1
# else:
#     dp[0] = 1; dp[1] = 2;


# if N >= 3:
#     for n in range(2, N):

#             dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])


import numpy as np
N, M = map(int, input().split())
A = np.array([int(input()) for _ in range(M)], dtype = int)

MOD= 1000000007
dp = np.zeros(N, dtype = int)
if M != 0:
    dp[A - 1] = -1

if dp[0] == -1 and dp[1] == -1:
    pass
elif dp[0] == -1:
    dp[1] = 1
elif dp[1] == -1:
    dp[0] = 1
else:
    dp[0] = 1
    dp[1] = 2


# if N >= 3:
#     for n in range(2, N):

#             dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])


import numpy as np
N, M = map(int, input().split())
if M == 1:
    A = int(input())
else:
    A = np.array([int(input()) for _ in range(M)], dtype = int)

MOD= 1000000007
dp = np.zeros(N, dtype = int)
# dp[A - 1] = - 1
# if dp[0] == -1 and dp[1] == -1:


#     dp[1] = 1

#     dp[0] = 1
# else:
#     dp[0] = 1; dp[1] = 2;


# if N >= 3:
#     for n in range(2, N):

#             dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])


import numpy as np
N, M = map(int, input().split())

MOD = 1000000007
dp = np.zeros(N, dtype = int)
if M != 0:
    A = np.array([int(input()) for _ in range(M)], dtype = int)
    dp[A - 1] = -1

if dp[0] == -1 and dp[1] == -1:
    pass
elif dp[0] == -1:
    dp[1] = 1

#     dp[0] = 1
# else:
#     dp[0] = 1
#     dp[1] = 2


if N >= 3:
    for n in range(2, N):
        if dp[n] != -1:
            dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])


import numpy as np
N, M = map(int, input().split())
if M == 1:
    A = int(input())
else:
    A = np.array([int(input()) for _ in range(M)], dtype = int)

MOD= 1000000007
dp = np.zeros(N, dtype = int)
dp[A - 1] = - 1
# if dp[0] == -1 and dp[1] == -1:


#     dp[1] = 1

#     dp[0] = 1
# else:
#     dp[0] = 1; dp[1] = 2;


# if N >= 3:
#     for n in range(2, N):

#             dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])


N, M = map(int, input().split())

dp = [1, 2]
A = [int(input()) for _ in range(M)]
if M != 0:
    if M >= 2 and A[0] == 1 and A[1] == 2:
        dp = [0, 0]
    elif A[0] == 1:
        dp = [0, 1]
    elif A[0] == 2:
        dp = [1, 0]
else:
    A = [0]

MOD = 1000000007

if N == 1:
    print (1)
elif N == 2:
    print (dp[-1])
else:
    cnt = 0
    for n in range(2, N):
        while(cnt < M - 1 and A[cnt] < n + 1):
            cnt += 1
        if A[cnt] == n + 1:
            dp[0] = dp[1]
            dp[1] = 0
        else:
            new_val = (max(dp[0], 0) + max(dp[1], 0)) % MOD
            dp[0] = dp[1]
            dp[1] = new_val

    print (dp[-1])


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted