Comments

I wanna become a Grandmaster, can you help me?

Actually , problem E has a solution in only $$$O(N^4)$$$ with simple convex hull trick . You can check my solution here .