Demo entry 6361922

s

   

Submitted by anonymous on May 05, 2017 at 20:44
Language: C++. Code size: 352 Bytes.

void build(int x, int L, int R)
{
	
	nodes[x].left=L;
	nodes[x].right=R;
	
	if(L==R)
	{
		nodes[x].max=nums[L];
		nodes[x].min=nums[L];
		return ;
	}
	
	int mid=(L+R)/2;
	build(tl(x),L,mid);
	build(tr(x),mid+1,R);
	nodes[x].max=max(nodes[tl(x)].max,nodes[tr(x)].max);
	nodes[x].min=min(nodes[tl(x)].min,nodes[tr(x)].min);
	return ;
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).