wages[i] is what the person standing i-th is asking for. You must hire exactly hires people, one per round.
In each round the manager only looks at the first window people in the line and the last window people (if fewer than 2 · window people remain, they can see everyone). Of those in view, the one asking for the least is hired; on a tie, the one who stood earlier in the original line wins. The hired person leaves and the line closes up.
Return the total cost of all the hires.wages=[5, 9, 4, 8, 6, 3, 7], hires=3, window=2 → 12
First we look at [5, 9] and [3, 7] and take 3. Then [5, 9] and [6, 7], take 5. Then [9, 4] and [6, 7], take 4. Total 3 + 5 + 4 = 12. The 8 in the middle was never in view.
wages=[2, 6, 2, 6], hires=3, window=3 → 10
The windows overlap, so everyone is in view: 2 + 2 + 6 = 10.
wages=[4, 1, 1, 4], hires=1, window=1 → 4
wages=[5, 9, 4, 8, 6, 3, 7], hires=3, window=2
12
Run checks the first 3 tests in your browser. Submit checks all 100 tests on the server, hidden ones included.