ll@n,@a[n],@b[]; Heap>>h; h.malloc(n); ll mn=1d9,mx=0; rep(i,n){ ll x=min(a[i],b[i]); h.push({x,{abs(a[i]-b[i])>>1,2}}); mn?=x; } ll z=mx-mn; while(true){ auto c=h.pop(); if(c.second.second==0){ break; } ll x=c.first+c.second.first; h.push({x,{c.second.first,c.second.second-1}}); mx>?=x; z