Luo Gu $ P4755 \ Beautiful \ Pair $ maximum partition

Positive Solutions: maximum partition

Report problem solving:

Portal $ QwQ $

Ang consideration if already Imperial point $ X $ is the $ max $ a, and now requires the number of $ [l, r] $ satisfies $ a_x = max \ left \ {a_i \ right \}, i \ in [l , r] $, and $ a_l \ cdot a_r \ leq a_x $

Now enumeration $ $ L, $ R & lt found that there is a range of $, to $ a_r \ leq \ frac {a_x} {a_l} $, this can be used to maintain the array into tree Well $ QwQ $

So basically this can draw basic idea of ​​the problem? First, find the maximum range of $ x $, respectively, to find the answer to $ x $ both sides, then crossed the statistical contribution of $ x $. $ L consider enumeration $, then for $ r $ Fenwick tree on the line directly engage the next, but found too many points if $ l $ is also not available, so consider a small enumeration of $ size $ side.

The complexity and heuristic merge complexity is the same, to $ O (nlogn) $, then add complexity Fenwick tree, the total complexity on two of the $ log $

$over$?

Guess you like

Origin www.cnblogs.com/lqsukida/p/11494906.html