The meaning of problems: length 1E9 $ $ $ A $ interval subscript $ [0,1e9-1] $, $ n-number of input intervals $, $ [l_i, r_i] $ Class interval is 1, the balance -1, and asked how many intervals greater than 0. solution: read the blog from the big brother, the point can produce only a maximum contribution of $ 3e7 $ months, which means first seeking a prefix and then painted map should look like.
Worst is the case, it can be influential only $ 3e7 $ points (possibly segmented) , then the question is, how to obtain this $ 3e7 $ points. From the blog Gangster
Why? Very simple in the eyes of big brother, I drew a diagram to understand it.
Obviously a front of $ f [i] $ add back $ g [i + 1] $ than the length between the two large sections joined together on the matter.(I really too dishes) Then after processing, the processing is equivalent to
a prefix, and such, there are several requirements for all positions in front of him he is smaller than a prefix. If the range is a little on the small tree with an array of requirements about gone, $ 3e7log (3e7) $ apparently timed out. See this prefix and, before and after item maximum error is only $ 1 $, upper and lower bounds biggest difference does not exceed $ 3e7 $, and then make a prefix and this sum. A number indicates the number of occurrences of one array, and $ sum [m] = sum [ m-1] + b [m] $, and updates the prefix, the answer is $ ans + = sum [m- 1] $. The middle there are some details to be processed