Analysis:
Test binary. The simple simulation will time out, and the optimized time is right, but the binary speed is faster. Pay attention to the following points:
(1): If a sequence D1... dn. If we calculate the sum of Di to Dj, we can calculate the sum of D1 to Dj, and the sum of D1 to Di, and the result is sum1-sum2;
(2): Then we will search for the m + sum [I] value.
<Stdio. h> <algorithm> <cstring> <vector> <cctype> <iomanip> <cmath> <map> Max_Int = Max_required = <Node> binary_find (target, low =, high = (low <= mid = (low + high)> (sum [mid] = (sum [mid] <= mid + high = mid-(scanf (, & n, & m )! = (I =; I <= n; I ++, & = sum [I-] + Min = (I =; I <= n; I ++ target = m + res = (sum [res]-sum [I]-m >=& & sum [res]-sum [I]-m <= (sum [res]-sum [I]-m <= sum [res]-sum [I]-= I + = (sum [res]-sum [I]-m = = I + = (I =; I <V_node.size (); I ++ View Code