Company: Texas
Difficulty: medium
Form a Team From Both Ends Repeatedly select one employee until `team_size` employees have been selected. At each step, consider the first `k` and last `k` remaining employees (or all remaining employees when fewer than `k` remain). Select the highest score among those candidates; if scores tie, select the employee with the lowest current index. Remove that employee and add the score to the answer. Input First line: `n`. Second line: `n` scores. Third line: `team_size k`. Output Print the sum of selected scores. Constraints `1 ≤ n ≤ 100000`, `1 ≤ score[i] ≤ 10^9`, `1 ≤ team_size, k ≤ n`. Example Input: `9 / 17 12 10 2 7 2 11 20 8 / 3 4` Output: `49`