Fjut Winter vacation homework up pose

Source: Internet
Author: User

Test instructions is very easy to understand, for the posture 0, the data is very small, it is easy to think of the direct cycle of violence to complete the task of solving. Put data into the array arr, loop i,j control all interval counts and. The results are recorded in the Vis.

When we look at the data changes, we find that the data is getting bigger and the 0 posture will time out. This is what we can do with the prefix array and processing. Using sum[i] to denote the 0~i of the term, then the interval i~j and can be calculated directly by the sum[j]-sum[i]. The sum array can be processed at the input, avoiding the time spent on each calculation and the resulting i~j.

Building the sum array

preprocessing, ans count.

Up to 2, the big data for each group was removed by 1-2. Although the Ai,qi decreased. But in fact, sum is easy to overflow

This is where we will continue to optimize the algorithm. We choose to optimize this part. We think of two points using the first n and the characteristic of an ascending sequence. See the notes when programming.

So we succeeded in optimizing the two-layer for to 10%, and Lower__bound was a handwritten binary nether function.

Up Posture 3, we find a feature that is particularly problematic, then we have a higher degree of complexity in each of these issues. We also notice that a detail data range is 10^6, then we can use the method of the array tag to calculate all the results, it is more classical to tag the data in the array tag. Either positive or negative can use two arrays, or a larger array, for example, 200 0000 of the array, the 100th 0000 is the demarcation. Subscript minus 100 0000 is the actual size, TMP is the maximum size of the array, anti-cross

Fjut Winter vacation homework up pose

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.