All about problems in Volume 118. If there is a thread about your problem, please use it. If not, create one with its number in the subject.
Moderator: Board moderators
2 posts • Page 1 of 1
OK, I've figured out how for a given M to split the sum into two parts. The first part can be cached independent of M (for given p), the other part is dependent on M, and has to be recalculated for every M (again, for given fixed p). I get TLE. Is this the approach you took? Do you answer each query in O(M) time?