A very good line of the topic of the tree
It is a key operation to add a linear table to each node.
The linear table is within the range of this node, it is sorted from small to large according to a array, then A[i] >= a[j] and B[i] >= B[j] This J
Also use (A[x]-a[y]) * (B[z]-b[y]) <= (A[y]-a[z]) * (b[y]-b[x), this y all removed, to ensure the monotonicity of the linear table
Then we can use two points to find the answer.
As for the complexity of time
Line tree each layer of the linear table inside a total of n points, a total of LGN layer, each layer has a sort of what, the time complexity of the achievement is O (n lg^2 N)
In addition, the query has Q times, each recursive search interval is LGN times, two points is lgn times, the query time is O (q LG ^2 N)
Total time complexity is O (n lg^2 n + q LG ^2 N)
Also, you can sort the points of time without using two points, and then, the most nlgn times.