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


  • 2
    98765432123456789  commented on Jan. 15, 2024, 1:44 p.m.

    Pretty sure the points(r, K) is supposed to be points(r, R) for rock


    • 1
      d  commented on Jan. 15, 2024, 8:39 p.m.

      fixed