区间最值板子
struct BIT
{
    LL  h[(int)1e5 + 9], n;
    void init(int x)
    {
        n = x;
        f(i,1,n)update(i);
    }
    void update(int x)
    {
        while(x<=n){
            h[x]=aa[x];
            int low=lowbit(x);
            for(int i=1;i<low;i<<=1)h[x]=min(h[x],h[x-i]);
            x+=lowbit(x);
        }  
    }
    LL gmin(int l, int r)
    {
        LL ans = 1e18;
        while (r >= l)
        {
            ans = min(ans, aa[r]);
            r--;
            while (r - lowbit(r) >= l)
            {
                ans = min(h[r], ans);
                r -= lowbit(r);
            }
        }
        return ans;
    }
};
上一篇
下一篇