You are playing a one-player game where several cells are arranged around a circle, and each cell contains a value. You have a bank that is initially empty, and you start on the 0-th cell. On each turn, you throw a typical six-sided die (each side has a distinct number between 1 and 6), and you move clockwise the number of cells indicated on the die. The value in the cell that you land on will be added to the bank. The goal is maximize the value of the bank.
Unfortunately, the sum of all the values on the cells is negative, so the expected value of the bank after a long game is also negative. Therefore, you should stop the game at the proper time.
You will be given a int[] cells that contains the values of the cells in clockwise order. The 0-th element of cells is the value of the 0-th cell. Return the expected value of the bank if you play optimally. See examples for further clarification.
|