Peace on you code forces Community
Currently, I'm trying to solve this problem.
I think the solution is a standard Mo algorithm,
I think the minimum cost will be to give the highest frequency value = 1 and the next highest frequency value = 2 and so on,
but How to compute the answer for each query,
I have tried to store each frequency in a set and for each frequency store the number it repeated but it gives TLE in test 15, I also see some code in git hub but I didn't understand what he is doing.
can you help, thank you.