Thanks a lot to Mathias Kern for this new chapter from life of Easter Bunnies!
You had so much fun with the first game of Easter egg throwing,
that you come back after a while to play again. The N=777_777
bunnies have practised, and this time each of
their throws can land anywhere in an array with cells numbered from 1
to N
. The bunnies throw a single egg
each. After the throw by the i-th
bunny, the bunny gives you a subarray [first(i), last(i)]
, and you can pick
any cell from this subarray and win the number of eggs in that cell. Important: you do not remove any
eggs from the array after winning eggs, i.e. there will be N
eggs in the array after all throws.
What is the highest total sum of eggs that you can win across all throws?
Input: A single integer X0
that is used as the seed for the Linear Congruential Generator introduced in the
problem 25 - use A=445
, C=700001
and M=2097152
.
Generate 3*N
random values, transform them via value % N + 1
to the range 1 .. N
, split them into N
triplets, and use the i-th
triplets (t(i), a(i), b(i))
to establish the cell t(i)
for the i-th
throw and
the i-th
subarray you can chose from as [min(a(i),b(i)), max(a(i),b(i))]
.
Output: The highest total sum of eggs that you can win across all throws.
Example: For X0=0
, the answer is 2_258_544
.