Problem H
Sequential Yahtzee
Danny has a hand-held game of Yahtzee that he likes to play
(how 90’s!). The object of Yahztee is to score points by
placing the result of rolls of
Category |
Scoring |
Category |
Scoring |
|
|
|
total of all |
|
|
|
total of all |
|
|
Full House |
|
|
|
Small Straight |
|
|
|
Long Straight |
|
|
|
Chance |
total of all |
Yahtzee |
|
A
A game consists of
In regular Yahtzee you have your choice of which of the
scoring categories to use after every round – in fact, the
decision on which category to use is one of the challenges of
Yahtzee. Danny normally plays this way, but as we said he plays
A LOT of Yahtzee, so sometimes he like to switch things up a
bit. One of his favorite variations is something he calls
sequential yahtzee. In this version, the only category
you can use after the first set of rolls is the
For example, suppose there’s a glitch in Danny’s game and
the dice only roll
Danny keeps track of all the dice rolls in the game and
often wonders if he could have done better than he did in a
game of sequential yahtzee, assuming that the same overall
sequence of dice appears regardless of the way he chooses to
re-roll dice in any given round. Another example should make
things clear. Suppose the sequence of dice is that of the
second sample input. If Danny assigns the first five dice to
the “
Your job is simple: given a sequence of consecutive dice rolls, what’s the maximum score possible in a game of sequential yahtzee? Well, maybe it’s just the description of the problem that’s simple.
Input
Input starts with a line containing an integer
Output
Display the maximum possible sequential yahtzee score using
the given dice rolls, filling in all
Sample Input 1 | Sample Output 1 |
---|---|
65 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 |
70 |
Sample Input 2 | Sample Output 2 |
---|---|
76 3 1 1 1 1 1 4 2 5 2 6 1 3 5 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 1 1 2 2 1 2 3 4 5 1 2 3 4 5 1 1 6 1 6 6 6 6 1 1 1 1 1 4 |
340 |