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