#C832. Balanced Request Distribution

    ID: 52289 Type: Default 1000ms 256MiB

Balanced Request Distribution

Balanced Request Distribution

You are given n requests with associated response times, and m servers. Your task is to assign each request to one of the servers such that:

  • Each server receives at least one request.
  • The maximum total response time among all servers is minimized.
  • If multiple distributions yield the same maximum total response time, choose the one that maximizes the minimum total response time.
  • If there is still a tie, choose the distribution that balances the load as evenly as possible.

Requests are numbered from 1 to n in the order they appear. Servers are numbered from 1 to m, and the answer should output for each request the server number (1-indexed) it is assigned to.

Note: It is guaranteed that mn.

Example:

Input:
7 3
5 3 9 1 6 2 8

Possible Output: 3 2 1 1 3 1 2

</p>

inputFormat

The first line contains two integers n and m separated by a space.

The second line contains n space-separated integers, representing the response times of the requests.

outputFormat

Output a single line containing n space-separated integers, where the i-th integer (1-indexed) represents the server number to which the i-th request is assigned.

## sample
7 3
5 3 9 1 6 2 8
3 2 1 1 3 1 2

</p>