Collect
TCO08 Round 4 · 2008-01-21 · by lars2520
Problem Statement
Assuming optimal play, what is the maximum expected score for a given N and K?
Notes
- If you elect not to reroll a die in one round, you may not reroll it in any subsequent round.
Constraints
- N will be between 1 and 10, inclusive.
- K will be between 1 and 100, inclusive.
1 1 Returns: 3.5
Rolling 1 die once gives an expected value of 3.5.
1 2 Returns: 4.249999999999999
If you can roll twice, you should keep a 4, 5, or 6 on the first round, and reroll a 1, 2, or 3. Thus, half the time you'll reroll and expect 3.5, while the other half the time you'll expect to get a 5 (the average of 4, 5 and 6). Thus, the overall expected value is (3.5+5)/2 = 4.25
2 2 Returns: 6.262345679012343
On the first roll, lock both if you have two threes or better. Otherwise keep the higher of the two dice if it is over 3. Otherwise, reroll both.
1 1 Returns: 3.5
1 2 Returns: 4.249999999999999
Submissions are judged against all 145 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Collect with a public method double expected(int N, int K) · 145 test cases · 2 s / 256 MB per case