Author: Timur Degteari
Prepared by: Timur Degteari
This problem requires a direct simulation of the conditions described in the statement. We simply iterate through each moment of time and verify whether the finger positions are feasible.
For each second from to , perform the following check:
Among the three values s_{1,i}, s_{2,i}, s_{3,i}, identify all positive values (i.e., values greater than ). Let denote the minimum of these positive values, and denote the maximum.
If no positive values exist at time (all strings are either not played or played open), then Mr. T can trivially handle this moment—proceed to the next second.
Otherwise, verify that the stretch requirement is satisfied: y - x \le 3. If this condition holds, continue to the next second. If it fails, output "No" along with as the first moment when the stretch becomes impossible.
If all seconds pass the check, output "Yes"—Mr. T can play the entire song.
Time complexity: , since we perform a constant-time check for each of the seconds.