mapa,b; ll@n,@q; a[-1]=0; b[n]=n; rep(q){ ll@t,@x; if(t==1){ auto i=a.lower_bound(-x); auto j=b.lower_bound(x); wt(min(i->first+x+i->second,j->first-x+j->second)); } if(t==2){ ll@c; auto i=a.lower_bound(-x); if(i->first+x+i->second>c){ a[-x]=c; } auto j=b.lower_bound(x); if(j->first-x+j->second>c){ b[x]=c; } } }