Editorial for COCI '08 Regional #2 Majstor


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

We use the algorithm given in the problem statement to calculate Sven's score. For each round, compare Sven's symbol with the other symbols and add the appropriate number of points to the score.

The largest number of points Sven could have scored can be calculated by trying all three symbols in every round and using the one that scores best.

This is easily done if we write a helper function points(r, symbol) that takes two arguments, the round number s and the symbol Sven supposedly shows in that round. If A and B are the two numbers we want to calculate for a round (the actual score and the largest possible score), we can calculate them as:

\displaystyle \begin{align*}
A &= A+points(r, Sven[r]) \\
B &= B+\max\{points(r, \texttt S), points(r, \texttt P), points(r, \texttt R)\}
\end{align*}


Comments

There are no comments at the moment.