Assume you've selected by maximum Z Then if Zmin > Z'max the surfaces do not overlap (minimax test)
No problem: paint S then S'