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

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

The iith chocolate fills your heart with aia_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 iith chocolate then you cannot choose (i+1)(i + 1)th chocolate or (i1)(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

a1=13a2=14a3=2a4=3a5=1a6=5a7=4a8=18a9=17a10=19a11=5a12=6a13=9a14=1 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.

×

Problem Loading...

Note Loading...

Set Loading...