G, (BUPT 201)
Http://acm.bupt.edu.cn/onlinejudge/newoj/showProblem/show_problem.php? Problem_id = 201
There is an array a [] with a corresponding array C [], C [] with 0 or 1 stored, defining L (I, j) = min (A | I... J); Evaluate ans as the logarithm of all l (I, j) <K. If C [I] and C [J] are not equal, L (I, j) is infinite.
Two operations: 1. Output ans
0 I reverse C [I] value
Last thought: First, find the position with the closest I position to the right and the position with the value smaller than K, and then maintain the numbers of 0, 1 before and after each position (of course, you only need to maintain a value), and then each update only needs to add or subtract the value related to this element. This value can be O (1) * O (lgn) figured out...
No words to inspire ideas...
Be sure to use Longlong...
We need to have a solid foundation. We need to discuss more...