Rock-paper-scissors is a famous hand game played by two people. In this game, each of the players forms one of three possible hand gestures: rock, paper, or scissors. Both players do so at the same time, and they show their gesture to the opponent. The result of the game is determined by the two gestures shown. If they are the same, the game is a draw. Otherwise, the winning player is determined by the following rules:
In this problem, you are going to play rock-paper-scissors against a bag of dice. There are N dice in the bag. Each dice has some faces that show a picture of a rock, others with a picture of paper, and the remaining faces show scissors. On the outside, all dice look the same, so you cannot distinguish between them. However, on the inside each die can be biased in a different way. That is, if you roll a particular die, the probability of getting each of the three gestures is not necessarily uniform.
Your game will take N turns. The game starts with all N dice inside the bag. In each turn, you first choose a gesture you want to play. Then you choose a random die from the bag and roll it to generate your opponent's move. The die is then thrown away. (Hence, after all N turns are over, the bag will be empty, and you played against each die exactly once.)
The games you play against the dice are scored as follows:
You are given three
Your task is to find the strategy for this game that maximizes the expected total number of points you get. Compute and return the best possible expected score.