# 统计某一时刻的在线人数

#pragma once

const int N = 2 * 24 * 3600;

#define LSON(o) (o << 1)
#define RSON(o) ((o << 1) + 1)

class Node
{
public:
void setNode(int l, int r, int add, int sum)
{
this->l = l;
this->r = r;
this->sum = sum;
}

private:
friend class RMQ;
int l, r;
int sum;
};

Node node[N];

class RMQ
{
public:
RMQ()
{
tree = node;
}

void build(int o, int left, int right)
{
if (left == right)
{
tree[o].setNode(left, right, 0, 0);
}
else
{
int mid = (left + right) >> 1;
build(o * 2, left, mid);
build(o * 2 + 1, mid + 1, right);
tree[o].l = left; tree[o].r = right; tree[o].add = 0; tree[o].sum = 0;
}
}

void update(int o, int left, int right, int v)
{
if (left <= tree[o].l && right >= tree[o].r)
{
}
else
{
int mid = (tree[o].l + tree[o].r) >> 1;
if (left <= mid) update(LSON(o), left, right, v);
if (right > mid) update(RSON(o), left, right, v);
}

maintain(o);
}

int query(int o, int left, int right, int add)
{
if (left <= tree[o].l && right >= tree[o].r)
{
return tree[o].sum + add * (tree[o].r - tree[o].l + 1);
}
else
{
int mid = (tree[o].l + tree[o].r) >> 1;
int result = 0;
if (left <= mid)
{
}

if (right > mid)
{
}
return result;
}
}

private:
void pushdown(int o)
{
{
}
}

void maintain(int o)
{
if (tree[o].r > tree[o].l)
{
tree[o].sum = tree[LSON(o)].sum + tree[RSON(o)].sum;
}

tree[o].sum += tree[o].add * (tree[o].r - tree[o].l + 1);
}
Node* tree;

};