Horje
query for rmq using sqrt decomposition Code Example
query for rmq using sqrt decomposition
int query(int l, int r)
{
  int LB = l/Blk; //Blk = block size
  int RB = r/Blk;
  int minimum = INT_MAX;
  
  if(LB == RB) {
    for(int i=l; i<=r; i++) {
      minimum = min(minimum, arr[i]);
    }
  }
  else {
    for(int i=l; i<Blk*(LB+1); i++) minimum = min(minimum, arr[i]);
    for(int i=LB+1; i<RB; i++) minimum = min(minimum, seg[i]);
    for(int i=RB*Blk; i<=r; i++) minimum = min(minimum, arr[i]);
  }
  return min;
}




Cpp

Related
3. The method indexOf, part of the List interface, returns the index of the first occurrence of an object in a List. What does the following code fragment do? Code Example 3. The method indexOf, part of the List interface, returns the index of the first occurrence of an object in a List. What does the following code fragment do? Code Example
identity Code Example identity Code Example
robux 1M Code Example robux 1M Code Example
onclick show hide div jquery demo Code Example onclick show hide div jquery demo Code Example
sort vector from smallest to largest Code Example sort vector from smallest to largest Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9