# Tessellate S.T.E.M.S - Computer Science - School - Set 3 - Problem 5

Santa visited you night, he had $$n$$ chocolates. Each chocolate fills your heart with some amount of happiness.

The $$i$$th chocolate fills your heart with $$a_i$$ happiness. He placed the chocolates in front you in a table in this order - 1 (a_1) ,2 (a_2) ,3 (a_3)... n (a_n)

So Santa told you that you can choose as many chocolates you want to have but you cannot choose consecutive chocolates. (If you choose $$i$$th chocolate then you cannot choose $$(i + 1)$$th chocolate or $$(i - 1)$$th chocolate)

The total happiness is the sum of happiness of the choosen chocolates.

So obviously you want to maximize your total happiness.

So you are given n = 14

$a_1 = 13 \\ a_2 = 14 \\ a_3 = 2 \\ a_4 = 3 \\ a_5 = 1 \\ a_6 = 5 \\ a_7 = 4 \\ a_8 = 18 \\ a_9 = 17 \\ a_{10} = 19 \\ a_{11} = 5 \\ a_{12} = 6 \\ a_{13} = 9 \\ a_{14} =1$

This problem is a part of Tessellate S.T.E.M.S.

×