#include using namespace std; const int nmax=2e5+42; int n,m,k,inp[nmax]; struct info { long long id_max,maxi,lazy,sum,sz; }; info tree[3][nmax*4],idle; /* id=0-> normal id=1-> with <=m id=2-> with penalty */ info actual(info cur) { cur.maxi+=cur.lazy; cur.sum+=cur.lazy*cur.sz; cur.lazy=0; return cur; } info my_merge(info a,info b) { a=actual(a); b=actual(b); info ret; ret.sz=a.sz+b.sz; ret.sum=a.sum+b.sum; ret.lazy=0; if(a.maxi "< "<m) { int pos=tree[1][1].id_max; //cout<<"pos= "< "<