P1 Optimization

faster algorithm for P1, added timer to main