一点疑惑

P2801 教主的魔法

WeinaH @ 2024-07-03 14:03:49

AC的二分写法:

fo(l+1,i,r-1){
    ll l=L[i],r=R[i],re=0;
    while(l<=r){
        ll mid=l+r>>1;
        if(d[mid]+lazy[i]>=k) r=mid-1,re=R[i]-mid+1;
        else l=mid+1; 
    }
    ans+=re;
}

WA90的写法:

fo(l+1,i,r-1){
    ll l=L[i],r=R[i];
    while(l<r){
        ll mid=l+r>>1;
        if(d[mid]+lazy[i]>=k) r=mid;
        else l=mid+1; 
    }
    ans+=(R[i]-l+1);
}

两者有什么区别吗


|