Yep, with this problem I finished the editorial for SRM 593
I really intended to get it done in 48 hours, but I had an 8 hours delay from that objective. This is a problem that really needs you to get clever even after you understand how to solve it. It has a couple of good twists from the standard dp implementation.
It is a very cool problem. But sometimes I wonder how are targets physically able to solve these problems in less than an hour. Even after understanding it, I really needed a day to implement the code (and think/debug hard binary search stuff...)
I wonder if lambda abuse is suitable for editorial code. First-class functions really help with a problem that requires 4 binary searches... If it isn't suitable for editorial code then at least there is the Java version from the admins to compensate.
Don't forget to vote in this video so I can travel to the TCO :(