#P9780. [HUSTFC 2023] Azur Lane

[HUSTFC 2023] Azur Lane

Problem Description

You are a commander in the port area. You can strengthen your fleet by training “Commander Meowfficer”, which are trained from the corresponding “Meow Boxes”. Meow Boxes have kk levels; the higher the level, the rarer it is. Every day you will obtain some Meow Boxes (at least one), and then use “One-click Insert” to put these Meow Boxes into the “Meow Nest” for training. “One-click Insert” will put rarer Meow Boxes first (that is, after sorting by rarity from high to low, insert them one by one). The inserted Meow Boxes will be placed after the boxes that are already in the nest. At the end of each day, the system will automatically deduct an amount of money equal to the number of Meow Boxes currently in the Meow Nest. At the beginning, there are no Meow Boxes in your Meow Nest.

Because you are very lazy, you will wait until after nn days to open all the Meow Boxes together. When you enter the Meow Nest after nn days, you see mm Meow Boxes. Use a sequence aa of length mm to represent the levels of the Meow Boxes in the Meow Nest, ordered by the time they were inserted. However, you have already forgotten how many Meow Boxes you obtained each day during these nn days, and you even forgot what nn was. Clearly, there are many possible situations. You want to know: for every integer nn satisfying 1nm1 \leq n \leq m, among all possible situations, what is the minimum total amount of money that could have been deducted over these nn days?

Input Format

The first line contains two integers m (1m106)m\ (1 \leq m \leq 10^6) and k (1k106)k\ (1 \leq k \leq 10^6), representing the number of Meow Boxes in the Meow Nest and the maximum level of Meow Boxes, respectively.

The second line contains mm integers a1,a2,,am (1aik)a_{1}, a_{2}, \ldots, a_{m}\ (1 \leq a_i \leq k), representing the levels of the Meow Boxes arranged in the Meow Nest.

Output Format

Output one line with mm integers separated by spaces. The ii-th integer represents, when n=in=i, the minimum total amount of money that could be deducted among all possible situations. If there is no valid situation, output 1-1.

3 3
2 3 1

-1 4 6 
8 4
3 2 4 2 1 2 3 2

-1 -1 -1 21 22 25 29 36 

Hint

Explanation for Sample 1:

When n=1n=1, it is impossible to obtain these 33 Meow Boxes within one day (the level of the second Meow Box is greater than the level of the first Meow Box, which does not follow the rule that “One-click Insert” inserts from high to low), so output 1-1.

When n=2n=2, on the first day you obtain the first Meow Box; at this time there is 11 Meow Box in the Meow Nest, so the cost for that day is 11. On the second day you obtain the last two Meow Boxes; at this time there are 33 Meow Boxes in the Meow Nest, so the cost for that day is 33. Therefore, the total amount of money is 44.

When n=3n=3, each day you obtain one Meow Box in order, and the total amount of money is 1+2+3=61+2+3=6.

Translated by ChatGPT 5