Assign stations to two handlers to minimize the total processing time.
You are given n stations that must be processed in order from 0 to n-1. Station i has a workflow type workflow[i] (1-indexed type id). There are two handlers, and each station must be processed by exactly one handler. For a station of type t, if a handler processes it immediately after processing another station of the same type t, it takes shortPrep[t] time; otherwise (different type, or the handler's first ever station) it takes longPrep[t]. Assign each station to one of the two handlers to minimize the total processing time, and return that minimum total time.
Example: workflow = [1, 2, 1, 2], longPrep = [10, 6, 5], shortPrep = [4, 2, 4] gives 22. Handler A: station 0 (type 1) takes 10; Handler B: station 1 (type 2) takes 6; Handler A: station 2 (type 1) takes short 4; Handler B: station 3 (type 2) takes short 2. Total = 10 + 6 + 4 + 2 = 22.
Community answers
Related questions
Order units across two stations to minimize total time after erasing one b[i].Find the minimum total request processing time for a conveyor belt and storage system.Related courses


