302836: CF549G. Happy Line

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Happy Line

题意翻译

给定一个 $n$ 个元素的整数序列 $a$, 任意时刻对于任一对**相邻元素** $(a_{i-1},a_i)$,若 $a_{i-1} > a_{i}$ 则要依次执行如下两个操作: ```a[i-1]--,a[i]++```,然后交换 $a_{i-1}$ 和 $a_i$ 的位置。 经过若干次 1、2 操作后,若能使整个序列变成**非降的**,则输出最终的序列;否则输出 ```:(``` 。 $1 \leq n \leq 2\times 10^5, 0 \leq a[i] \leq 10^9$。

题目描述

Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of $ n $ Berland residents lined up in front of the ice cream stall. We know that each of them has a certain amount of berland dollars with them. The residents of Berland are nice people, so each person agrees to swap places with the person right behind him for just 1 dollar. More formally, if person $ a $ stands just behind person $ b $ , then person $ a $ can pay person $ b $ 1 dollar, then $ a $ and $ b $ get swapped. Of course, if person $ a $ has zero dollars, he can not swap places with person $ b $ . Residents of Berland are strange people. In particular, they get upset when there is someone with a strictly smaller sum of money in the line in front of them. Can you help the residents of Berland form such order in the line so that they were all happy? A happy resident is the one who stands first in the line or the one in front of who another resident stands with not less number of dollars. Note that the people of Berland are people of honor and they agree to swap places only in the manner described above.

输入输出格式

输入格式


The first line contains integer $ n $ ( $ 1<=n<=200000 $ ) — the number of residents who stand in the line. The second line contains $ n $ space-separated integers $ a_{i} $ ( $ 0<=a_{i}<=10^{9} $ ), where $ a_{i} $ is the number of Berland dollars of a man standing on the $ i $ -th position in the line. The positions are numbered starting from the end of the line.

输出格式


If it is impossible to make all the residents happy, print ":(" without the quotes. Otherwise, print in the single line $ n $ space-separated integers, the $ i $ -th of them must be equal to the number of money of the person on position $ i $ in the new line. If there are multiple answers, print any of them.

输入输出样例

输入样例 #1

2
11 8

输出样例 #1

9 10 

输入样例 #2

5
10 9 7 10 6

输出样例 #2

:(

输入样例 #3

3
12 3 3

输出样例 #3

4 4 10 

说明

In the first sample two residents should swap places, after that the first resident has 10 dollars and he is at the head of the line and the second resident will have 9 coins and he will be at the end of the line. In the second sample it is impossible to achieve the desired result. In the third sample the first person can swap with the second one, then they will have the following numbers of dollars: $ 4\ 11\ 3 $ , then the second person (in the new line) swaps with the third one, and the resulting numbers of dollars will equal to: $ 4\ 4\ 10 $ . In this line everybody will be happy.

Input

题意翻译

给定一个 $n$ 个元素的整数序列 $a$, 任意时刻对于任一对**相邻元素** $(a_{i-1},a_i)$,若 $a_{i-1} > a_{i}$ 则要依次执行如下两个操作: ```a[i-1]--,a[i]++```,然后交换 $a_{i-1}$ 和 $a_i$ 的位置。 经过若干次 1、2 操作后,若能使整个序列变成**非降的**,则输出最终的序列;否则输出 ```:(``` 。 $1 \leq n \leq 2\times 10^5, 0 \leq a[i] \leq 10^9$。

加入题单

上一题 下一题 算法标签: