Finally! , this one was hard. Since I couldn't finish it during the 48 hours window I usually reserve, I had to use small portions of free time during the week to finally understand the very helpful comments that rng_58 added to tourist's passing code. Yesterday I finally got it. But I had to do homework so I waited till today to finish it.
This was tough, but in hindsight it doesn't look so hard. I think it was important to have a good starting point with the easy division 2 version of the problem. I had to update the explanation for that problem so I can use it as a base.
I have to add the summary to the editorial (did I mention how much I hate writing the summary?), I will also do language corrections and those things and then the editorial will be ready to publish.