Optimal Two-machine Scheduling in a Flexible Flow System