Editorial for Back to School '24 P1 - Kicking


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.

Author: NK

You can solve each row independently. Iterate through each row, keeping track of the last A. As you go along, for each B you encounter, check if it is within K of the last A. This approach can also be used to find the answer for Team A.

Time Complexity: O(NM)


Comments

There are no comments at the moment.