#P8686. [蓝桥杯 2019 省 A] 修改数组

[蓝桥杯 2019 省 A] 修改数组

Description

Given an array A=[A1,A2,AN]A=[A_1,A_2, \cdots A_N] of length NN, the array may contain repeated integers.

Now Xiaoming wants to modify it into an array with no repeated integers using the following method. Xiaoming will modify A2,A3,,ANA_2,A_3, \cdots ,A_N in order.

When modifying AiA_i, Xiaoming checks whether AiA_i has appeared in A1A_1 to Ai1A_{i-1}. If it has, Xiaoming adds 11 to AiA_i. If the new AiA_i still appears before, Xiaoming keeps adding 11 to AiA_i until AiA_i does not appear in A1A_1 to Ai1A_{i-1}.

After ANA_N is also modified as above, it is clear that there will be no duplicate integers in array AA.

Given the initial array AA, please compute the final array AA.

Input Format

The first line contains an integer NN.

The second line contains NN integers A1,A2,,ANA_1,A_2, \cdots ,A_N.

Output Format

Output NN integers, in order: the final A1,A2,,ANA_1,A_2, \cdots ,A_N.

5
2 1 1 3 4
2 1 3 4 5

Hint

For 80%80\% of the test cases, 1N100001 \le N \le 10000.

For all test cases, 1N1051 \le N \le 10^5, 1Ai1061 \le A_i \le 10^6.

Lanqiao Cup 2019 Provincial Contest A Group Problem H.

Translated by ChatGPT 5