This is my code for SUPW in python-
n = int(input()) c = list(map(int,input().strip().split())) if n <= 3: print(min(c)) else: cost = [c,c,c] for i in range(3,n): cost.append(c[i] + min(cost[i-3:i])) print(min(cost[n-3:]))
This is giving accepted for all test cases except for test case 2 in which it is giving Runtime Error. Can someone tell me the reason or provide a test case where it fails.
So what I have done is that-
Cost[i] = min time if we work that day. So cost = c, cost = c, cost = c And for the rest it is c[i] + min of the previous 3 elements. And the answer is the min of the last 3 elements.