Comments

I think it should be *it > x in this line. while (it != minus.end() && (*it < x || wmax * (long long)(*it — x + l) <= abs(*it + x + l)))

Great!

Thanks. But I understood this one. I was asking for explanation to the solution using Fibonacci sequence.

Please explain second solution of problem B, Mahmoud and Triangles