/// Gheorghies Alexandru - difference arrays solution #include using namespace std; typedef long long ll; typedef long double ld; typedef pair pll; typedef pair pld; const ll LGMAX=20,NMAX=2e5+5; vector smen[NMAX]; /// smen (smenul lui mars) is the romanian term for difference arrays ll ans[NMAX]; pll v[NMAX]; void tc(){ ll n,k; cin>>n>>k; for(ll i=0;i>v[i].first; v[i].second=i; } sort(v,v+n); ll r=0; for(ll l=0;l cnd; for(ll i=0;i0) cnd.insert(it); else cnd.erase(cnd.lower_bound(-it)); } ans[v[i].second]=*cnd.rbegin(); } for(ll i=0;i>t; while(t--) tc(); return 0; }