Why is the giving Time limit, its O(n*k) Time complexity

mapper = {}
import sys
def recursion(A,index,prev,B):
    if B == 0:
        return 0
    if index == len(A):
        return 0
    string_key = str(index)+"/"+str(prev)+"/"+str(B)
    if mapper.get(string_key)!=None:
        return mapper[string_key]
    trans = "B" if prev=="S" or prev=="" else "S"
    calc = A[index] if trans=="S" else -1*A[index]
    val1 = calc + recursion(A,index+1,trans,B-1)
    val2 = recursion(A,index+1,prev,B)
    mapper[string_key] = max(val1,val2)
    return mapper[string_key]

class Solution:
    def solve(self, A, B):
        global mapper
        mapper = {}
        return recursion(A,0,"",B)


Hey the problem is because B is given as 10^9 while N is only 500 if B is greater than N then it is simple stock buy and sell in infinite transaction try to optimize there.
Hope It would help.