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