A dynamic programming method for single machine scheduling