581463A - Mr. Perfectly Fine
Each $$$s_i$$$ can only be 00
, 01
, 10
, or 11
, corresponding to the decimal values, $$$0, 1, 2,$$$ and $$$3$$$. We can treat these as indexes in an array $$$a$$$ of size $$$4$$$. Index $$$1$$$ corresponds to learning skill 1, index $$$2$$$ to skill $$$2$$$, and index $$$3$$$ to both skills. Each index is initialized to $$$\infty$$$, meaning the skill is not learned yet, and is minimized with $$$m_i$$$ whenever the corresponding $$$s_i$$$ is read. Index $$$0$$$ can be ignored. Once all inputs are read, we check $$$a_3$$$ and $$$a_1+a_2$$$. If both are infinity, then no skill has been learned and we output -1. Otherwise, we output the minimum of $$$a_3$$$ and $$$a_1+a_2$$$.
Original problem: 1829C - Mr. Perfectly Fine, leads to official tutorial and all solutions including WS solution: 276753145