fork download
  1. x = [2,-1,4,0,3,5]
  2.  
  3. dp = [0]* len(x)
  4. dp[0] = x[0]
  5. dp[1] = x[0]
  6.  
  7. for i in range(2, len(x)):
  8. dp[i] = max(dp[i-1], x[i]+dp[i-2])
  9.  
  10. print(dp[5])
Success #stdin #stdout 0.07s 14068KB
stdin
Standard input is empty
stdout
11