This page is still under construction.

Parts of this page are still being built. What you see may change.

Scheduler

Interview

Time limit2sMemory limit256 MB

Summary
Simulate a priority scheduler for T seconds where the process with the largest p_i + t_i wins ties by smallest index, and report each process's total run time.
Level

Medium7 of 10

Topics
Simulation, Heap, Greedy, Implementation
Solved
No attempts yet

Problem

In the multitasking operating system <> there are NN processes running. Each process has a priority pip_i, which affects how often the process runs. The system has only one core on one processor to run things, so it has to distribute CPU time among these processes while taking their priorities into account.

The algorithm that decides which process runs at each moment works as follows. Besides the priority pip_i, each process also has a counter tit_i. Initially all tit_i equal 0. Then every second:

  1. The processes with the maximum value of pi+tip_i + t_i are chosen.
  2. Among those processes, the process with the smallest number ii is chosen.
  3. The chosen process ii runs for one second.
  4. For the chosen process ii, the value of tit_i is set to 0.
  5. For all other processes, the value of tit_i is increased by 1.

Model the work of the operating system for TT seconds and calculate how many seconds each process ran. All calculations and switches between processes are instant, so the running time of each process is an integer number of seconds.

Input

The first line contains two space-separated integers NN and TT: the number of processes in the operating system (1≤N≤1051 \le N \le 10^5) and the number of seconds to be modeled (1≤T≤1061 \le T \le 10^6).

The second line contains NN space-separated integers pip_i: the process priorities (0≤pi≤1050 \le p_i \le 10^5).

Output

In the only line of the output, print NN space-separated integers: how many seconds each of the processes ran.

Examples1

  1. Example 1

    Input
    3 10
    3 4 5
    
    Expected output
    3 3 4