void update(MAP & p , pii x){ MAP::iterator it = p.lower_bound(x.F), ini = it; if( it != p.end() && it->F == x.F && it->S <= x.S) return; if( it != p.begin() && (--it)->S <= x.S) return; it = ini; while( it != p.end() && it->S >= x.S) it++; p.erase( ini, it); p[x.F] = x.S; }
bool napraia(pii x, const MAP & p ){ MAP::const_iterator it = p.lower_bound( x.F); if( it == p.begin()) return true; return (--it)->S >= x.S; }