max cover algorithm