#P15063. [UOI 2024 II Stage] Creating an Array

    ID: 16992 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>贪心2024Special JudgeUOI(乌克兰)

[UOI 2024 II Stage] Creating an Array

题目描述

Sofiia gave Anton an array of digits\textbf{digits}! Although this array was not the first one he had seen, he did not consider it less interesting. After playing with the array, he did not notice how he broke it to a state where he could no longer restore the original.

He was very upset because there were almost countless ways to compose the initial array. However, he remembers an interesting property of the gift: $\sum_{i=1}^n \sum_{j=i}^n \operatorname{concat}(a_i, a_j)$, which means the sum of concatenations of all pairs of its elements, is \textbf{maximum} among all possible arrays made from these digits consisting of the same elements, as the gift.

In other words, we take all pairs of positions ii and jj such that jj is not to the left of ii (iji \le j). And add to the sum aiaj\overline{a_i a_j}, where ab\overline{ab} means the number that will result if we write the numbers aa and bb in order (or 10a+b10 \cdot a + b). This is called the concatenation of aa and bb.

For example, if Anton had an array [1,0,3][1,0,3], then the sum would be equal to $\overline{a_1 a_1} + \overline{a_1 a_2} + \overline{a_1 a_3} + \overline{a_2 a_2} + \overline{a_2 a_3} + \overline{a_3 a_3}$ = 11+10+13+00+03+33=7011 + 10 + 13 + 00 + 03 + 33 = 70.

Help Anton and print an array that has this property. If there are multiple answers, any of them can be output.

输入格式

The first line contains 1010 integers c0,c1,c2,c3,c4,c5,c6,c7,c8,c9c_0, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9 (0ci500 \le c_i \le 50) --- where cic_i corresponds to the number of digits ii in the initial array.

It is guaranteed that the sum of all numbers is greater than zero.

输出格式

Print an array consisting of $c_0 + c_1 + c_2 + c_3 + c_4 + c_5 + c_6 + c_7 + c_8 + c_9$ elements, and has the same properties as the array given by Sophia.

0 0 0 0 0 2 0 0 0 0
5 5
1 0 1 1 0 0 0 0 0 0
3 2 0

提示

In the second example, there are such possible arrays:

  • [0,2,3][0, 2, 3], the sum is equal to $\overline{a_1 a_1} + \overline{a_1 a_2} + \overline{a_1 a_3} + \overline{a_2 a_2} + \overline{a_2 a_3} + \overline{a_3 a_3}$ = 00+02+03+22+23+33=8300 + 02 + 03 + 22 + 23 + 33 = 83;
  • [0,3,2][0, 3, 2], the sum is equal to $\overline{a_1 a_1} + \overline{a_1 a_2} + \overline{a_1 a_3} + \overline{a_2 a_2} + \overline{a_2 a_3} + \overline{a_3 a_3}$ = 00+03+02+33+32+22=9200 + 03 + 02 + 33 + 32 + 22 = 92;
  • [2,0,3][2, 0, 3], the sum is equal to $\overline{a_1 a_1} + \overline{a_1 a_2} + \overline{a_1 a_3} + \overline{a_2 a_2} + \overline{a_2 a_3} + \overline{a_3 a_3}$ = 22+20+23+00+03+33=10122 + 20 + 23 + 00 + 03 + 33 = 101;
  • [2,3,0][2, 3, 0], the sum is equal to $\overline{a_1 a_1} + \overline{a_1 a_2} + \overline{a_1 a_3} + \overline{a_2 a_2} + \overline{a_2 a_3} + \overline{a_3 a_3}$ = 22+23+20+33+30+00=12822 + 23 + 20 + 33 + 30 + 00 = 128;
  • [3,0,2][3, 0, 2], the sum is equal to $\overline{a_1 a_1} + \overline{a_1 a_2} + \overline{a_1 a_3} + \overline{a_2 a_2} + \overline{a_2 a_3} + \overline{a_3 a_3}$ = 33+30+32+00+02+22=11933 + 30 + 32 + 00 + 02 + 22 = 119;
  • [3,2,0][3, 2, 0], the sum is equal to $\overline{a_1 a_1} + \overline{a_1 a_2} + \overline{a_1 a_3} + \overline{a_2 a_2} + \overline{a_2 a_3} + \overline{a_3 a_3}$ = 33+32+30+22+20+00=13733 + 32 + 30 + 22 + 20 + 00 = 137.