Обяснить что получается #include
using namespace std;
#define ll long long
vector DO(4000100,1e9);
vector DO2(4000100,1e9);
vector vec;
void add(ll nom, ll l, ll r, ll x, ll n)
{
if(l>r) return;
if(l>x) return;
if(x>r) return;
//cout«nom«" "«l«" "«r«" "«x«" "«n«endl;
if(l==r && r==x)
{
DO[nom]=n;
DO2[nom]=l;
return ;
}
ll mid=(l+r)/2;
add(nom*2, l, mid, x, n);
add(nom*2+1, mid+1, r, x, n);
if(DO[nom*2]>DO[nom*2+1])
{
DO2[nom]=DO2[nom*2+1];
}
else
DO2[nom]=DO2[nom*2];
DO[nom]=min(DO[nom*2],DO[nom*2+1]);
}
pair found(ll nom, ll l, ll r, ll nl, ll nr)
{
if(nr r)return {1e9,-1};
if(l==nl && r==nr)
{
return {DO[nom], DO2[nom]};
}
ll mid=(l+r)/2;
pair a1, a2;
a1=found(nom*2, l, mid,nl, min(nr, mid));
a2=found(nom*2+1, mid+1, r, max(nl, mid+1), nr);
if(a1 lch(500010,0);
for(i=0;i ,ll > > vv;
//cout«"HERE"«endl;
for(i=0;i otv(s+10,0);
ll no=1;
sort(vv.begin(),vv.end());
for(i=0;i p=found(1, 1, a, no, no);
//cout«"del "«p.first«" "«p.second«endl;
if(p.first!=0)add(1, 1, a, p.first, 1e9);
no++;
}
pair pol=found(1, 1, a, a1, a2);
//cout«"found "«pol.first«" "«pol.second«" "«a1«" "«a2«endl;
if(pol.first>=a1)otv[a3]=0; else
{
otv[a3]=pol.second;
}
}
for(i=1;i<=s;i++)
cout«vec[otv[i]]«endl;
}