#C1436. Team Assignment Problem

    ID: 44000 Type: Default 1000ms 256MiB

Team Assignment Problem

Team Assignment Problem

You are given a list of participants with their corresponding skill levels. Your task is to form as many teams as possible where each team consists of exactly k participants.

To form a team, first sort the list of skill levels in non-decreasing order. Then, assign the first k participants to the first team, the next k participants to the second team, and so on. Some participants may not be assigned to any team if the total number of participants is not a multiple of k.

The output should include:

  • The maximum number of teams formed.
  • A list of skill levels for participants assigned to teams (in sorted order).
  • A list of skill levels for participants that are not assigned to any team (in sorted order).
  • Note: The order within each list does not matter as long as it is sorted in non-decreasing order.

    inputFormat

    The input is read from standard input and consists of two lines:

    1. The first line contains two space-separated integers n and k, where n is the number of participants and k is the required number of participants in each team.
    2. The second line contains n space-separated integers representing the skill levels of the participants.

    outputFormat

    The output is printed to standard output and should consist of three lines:

    1. The first line contains a single integer representing the maximum number of teams formed.
    2. The second line contains the assigned skill levels (space-separated) for all teams in non-decreasing order. If no participant is assigned, output an empty line.
    3. The third line contains the remaining skill levels (space-separated) that were not assigned to any team in non-decreasing order. If all participants are assigned, output an empty line.
    ## sample
    8 3
    7 1 5 9 4 6 2 3
    2
    

    1 2 3 4 5 6 7 9

    </p>