Codeforces Beta Round #75 Igloo skyscraper

Source: Internet
Author: User



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.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.