#P2035. iCow Music Playback Simulation

    ID: 15317 Type: Default 1000ms 256MiB

iCow Music Playback Simulation

iCow Music Playback Simulation

Farmer John has purchased a new MP3 player, the iCow, to relax with some music after endless farm work. The iCow contains \(N\) songs numbered from 1 to \(N\), each with an initial weight \(R_i\). The play order is decided by the following algorithm:

  • The \(i\)th song has an initial weight \(R_i\) (\(1 \le R_i \le 10\,000\)).
  • At each step, the next song to play is the one with the highest weight. In case of a tie, the song with the smallest index is chosen.
  • After a song finishes playing, suppose its weight is \(W\). Its weight is then reset to 0 and distributed among the remaining \(N-1\) songs as follows:
    • Each of the other songs receives \(\lfloor W/(N-1) \rfloor\).
    • If \(W\) is not divisible by \(N-1\), the remaining \(W \mod (N-1)\) units are distributed one by one to the songs in increasing order of their indices (skipping the song that just played) until fully allocated.
  • This process is repeated after each song finishes playing.

Your task is to compute the sequence of the first \(T\) songs played according to this algorithm.

inputFormat

The first line contains two integers \(N\) and \(T\) (\(1 \le N \le 1000\), \(1 \le T \le 1000\)).

The second line contains \(N\) integers \(R_1, R_2, \ldots, R_N\) where \(1 \le R_i \le 10\,000\) representing the initial weights of the songs.

outputFormat

Output the numbers of the first \(T\) songs played according to the algorithm. The song numbers should be separated by spaces.

sample

3 3
2 4 6
3 2 1