Mathematics
Mathematics, 19.05.2021 18:30, chloelandry

In this game, there is a stack of n bricks. The ith brick in the stack is worth v[i] points (where v[0] is the value of the top brick). The players take turns removing either 1, 2, 3 or 4 bricks from the top of the stack. The player that removes a brick earns the number of points associated with the brick. The game ends when all the bricks have been removed, and the winner is the player who has earned the most points. For example, if v = [1, 1, 3, 4] and Smoov is the first player to move, then Smoov's optimal strategy is to take just the first brick (earning 1 point). Curly's optimal strategy is then to take the next two bricks (earning 4 points). Smoov then finishes by taking the last brick (earning 4 more points). Therefore, the maximum score Smoov can earn is 5. Assume that Smoov takes the first turn and that both Smoov and Curly play optimally. Given the list v of the values of the bricks (all integers greaterthanorequalto 0), output the maximum score Smoov can earn. (a) Define the subproblems to be solved in English. Solution: Let s_i denote the optimum score for whoever's turn it is when v_i is the top remaining brick. The subproblems are to compute s_i for each i from n - 1 to 0. (b) Define an appropriate recurrence for the subproblems. Solution: s_i = {0, i greaterthanorequalto n v[i] + max (min(s_i+2, s_i+3), v[i + 1] + min(s_i+3, s_i+4)), i < n For the particular input v = [1, 2, 0, 8, 0, 3, 3, 2], compute s_i for 0 lessthanorequalto i lessthanorequalto 7.

answer
Answers: 3

Other questions on the subject: Mathematics

image
Mathematics, 21.06.2019 19:30, JacobWat
He mass of a single atom of carbon can be found by dividing the atomic mass (12.01 g) by 6.022 x 10^23. which is the mass of a single carbon atom, correctly written in scientific notation with the correct number of significant figures?
Answers: 1
image
Mathematics, 21.06.2019 19:30, bigboss2984
Hey am have account in but wished to create an account here you guys will me with my make new friends of uk !
Answers: 1
image
Mathematics, 21.06.2019 22:30, fluffpupkiki
5. (04.07)which of the following exponential functions goes through the points (1, 12) and (2, 36)? (2 points)f(x) = 3(4)^xf(x) = 4(3)^-xf(x) = 3(4)^-xf(x) = 4(3)^x
Answers: 1
image
Mathematics, 22.06.2019 03:00, jdkrisdaimcc11
Gabrielle's age is three times mikhail's age. the sum of their ages is 40 . what is mikhail's age? __ years old
Answers: 2
Do you know the correct answer?
In this game, there is a stack of n bricks. The ith brick in the stack is worth v[i] points (where v...

Questions in other subjects:

Konu
Mathematics, 25.09.2019 05:30
Konu
Biology, 25.09.2019 05:30
Konu
Mathematics, 25.09.2019 05:30
Konu
Geography, 25.09.2019 05:30