Editorial for TLE '16 Contest 5 P2 - Playing Piano
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.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
First, note that since each chord spans 12 notes, there are only 12 unique chords to consider. Additionally, since the chords steps cycle every 12 steps, we can take every note modulo 12.
Consider that the super chord starts on note 1. Then use a two-pointer algorithm to find the longest interval containing no more than
Now, we repeat our solution for the other 11 chords and output the greatest answer found.
Time Complexity:
Comments