#K62217. Assign Problems to Teams
Assign Problems to Teams
Assign Problems to Teams
You are given n problems and k teams. Each problem has an associated difficulty (although the difficulty is not used in the assignment). Your task is to assign a problem to each team such that no two consecutive teams receive the same problem.
Formally, let \(a_1, a_2, \ldots, a_k\) be the sequence of problem indices (1-indexed) assigned to the teams. The requirement is that for every \(1 \leq i 1\) then \(n \ge 2\) so that a valid assignment is always possible.
inputFormat
The input is read from standard input and contains three lines:
- The first line contains an integer \(n\) denoting the number of problems.
- The second line contains \(n\) space-separated integers which represent the difficulties of the problems.
- The third line contains an integer \(k\) denoting the number of teams.
outputFormat
Output to standard output a single line containing \(k\) space-separated integers. Each integer is the 1-indexed problem number assigned to the corresponding team, ensuring that no two consecutive teams are assigned the same problem.
## sample5
3 1 4 1 5
3
1 2 1
</p>