链接:http://codeforces.com/problemset/problem/689/D
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+10;
struct tree
{
int l,r;
int a,b,ma,mi;
}tree[3*maxn];
int a[maxn],b[maxn];
ll ma,mi;
void Pushup(int rt)
{
tree[rt].ma=max(tree[2*rt].ma,tree[2*rt+1].ma);
tree[rt].mi=min(tree[2*rt].mi,tree[2*rt+1].mi);
}
void Buildtree(int rt,int l,int r)
{
tree[rt].l=l;
tree[rt].r=r;
if(l!=r)
{
Buildtree(2*rt,l,(l+r)/2);
Buildtree(2*rt+1,(l+r)/2+1,r);
Pushup(rt);
}
else
{
tree[rt].a=a[l],tree[