Untitled
unknown
plain_text
a year ago
562 B
11
Indexable
int quer(int &l,int &r,int &xx,int id=0,int ns=0,int ne=1e6)
{
if (ns>xx)
return -1e9;
if (tree[id]>=l)
return -1e9;
if (ns==ne)
{
return ns;
}
int left=2*id+1,right=left+1;
int md=(ns+ne)/2;
if (tree[right]<l && ne<=xx)
{
return quer(l,r,xx,right,md+1,ne);
}
if (tree[right]>=l)
{
return quer(l,r,xx,left,ns,md);
}
return max(quer(l,r,xx,left,ns,md), quer(l,r,xx,right,md+1,ne));
}Editor is loading...
Leave a Comment