HDU 6621 "K-th Closest Distance" (half + Chairman of the tree)

 

Portal

 

• the meaning of problems

  There are times $ m $ query, $ request asking each n-number of $, $ [L, R] $ $ p $ absolute value of the pitch region of nearly $ k $ and $ p $ the number of difference values;

•answer

  Half the answer, assuming that the answer to the current dichotomy $ x $, $ x $ then how to determine whether you can do?

  Analyzing only $ [L, R] $ interval value $ [px, p + x] $ $ SUM of the counted number is greater than $ equal to k;

  If the $ sum \ geq k $, then, x large, the range needs to be reduced, on the contrary, the range needs to be increased;

  How to quickly solve the $ [L, R] $ interval value in the number of the number of $ [px, p + x] $ of it?

  This is the title of the plate board chairman of the tree;

  See the time complexity is $ O (m \ cdot log (10 ^ 6) \ cdot log (10 ^ 6)) $, and the present problem to $ 15s $, completely therethrough;

•Code

  HDU6621.cpp

 

Guess you like

Origin www.cnblogs.com/violet-acmer/p/11705086.html