Optimally rescheduling jobs with a Last-In-First-Out buffer