Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Runtime Error in python code

Правка en1, от kkbhss, 2021-07-05 18:21:19

I am trying to solve Dima and Hares using python and getting a runtime error I don't Know why. Can someone tell me why the error is coming ?

My code is:

dp = [[-1 for i in range(5)] for j in range(3005)]
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
def fun(i ,n ,idx):
    if dp[i][idx]!=-1:return dp[i][idx]
    if idx==0:
        if(i==n-1): return a[n-1]
        dp[i][idx] = max(fun(i+1,n,1) +a[i],fun(i+1,n,0)+b[i])
    else:
        if(i==n-1): return b[n-1]
        dp[i][idx] = max(fun(i+1,n,1)+b[i],fun(i+1,n,0)+c[i])
    return dp[i][idx]
print(fun(0,n,0))

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский kkbhss 2021-07-05 18:21:19 764 Initial revision (published)