Happy Line

Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

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.

Input

The first line contains integer n (1 ≤ n ≤ 200 000) — the number of residents who stand in the line.

The second line contains n space-separated integers ai (0 ≤ ai ≤ 109), where ai 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.

Output

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.

Sample Input

Input
2
11 8
Output
9 10 
Input
5
10 9 7 10 6
Output
:(
Input
3
12 3 3
Output
4 4 10 

Hint

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.

 #include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; struct Node
{
int v;
int id;
}a[]; bool cmp(Node x,Node y)
{
return (x.v+x.id)<(y.v+y.id);
} int main()
{
int n;
int i,j;
scanf("%d",&n);
for(i=;i<=n;i++)
{
scanf("%d",&a[i].v);
a[i].id=i;
}
sort(a+,a+n+,cmp);
int flg=;
for(i=;i<=n;i++)
{
a[i].v=a[i].v-(i-a[i].id);
if(a[i].v< || (i>= && a[i].v<a[i-].v))
flg=;
}
if(flg==)
{
printf("%d",a[].v);
for(i=;i<=n;i++)
printf(" %d",a[i].v);
printf("\n");
}
else
{
printf(":(\n");
}
return ;
}

CodeForces 549G Happy Line的更多相关文章

  1. Codeforces 549G Happy Line[问题转换 sort]

    G. Happy Line time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  2. Codeforces 549G. Happy Line 馋

    非常有趣的贪婪: Let's reformulate the condition in terms of a certain height the towers, which will be on t ...

  3. codeforces A. Cinema Line 解题报告

    题目链接:http://codeforces.com/problemset/problem/349/A 题目意思:题目不难理解,从一开始什么钱都没有的情况下,要向每一个人售票,每张票价格是25卢布,这 ...

  4. 【CF 549G Happy Line】排序

    题目链接:http://codeforces.com/problemset/problem/549/G 题意:给定一个n个元素的整数序列a[], 任意时刻对于任一对相邻元素a[i-1]. a[i],若 ...

  5. codeforces B. Shower Line 解题报告

    题目链接:http://codeforces.com/contest/431/problem/B 题目意思:给出5 * 5 的矩阵.从这个矩阵中选出合理的安排次序,使得happiness之和最大.当第 ...

  6. [codeforces 549]G. Happy Line

    [codeforces 549]G. Happy Line 试题描述 Do you like summer? Residents of Berland do. They especially love ...

  7. [Educational Codeforces Round 16]B. Optimal Point on a Line

    [Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...

  8. Codeforces Round #189 (Div. 1) B. Psychos in a Line 单调队列

    B. Psychos in a Line Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/p ...

  9. Codeforces Round #466 (Div. 2) -A. Points on the line

    2018-02-25 http://codeforces.com/contest/940/problem/A A. Points on the line time limit per test 1 s ...

随机推荐

  1. Testcase篇

    1: forever @(); 等待,c触发event. forever @(`SOC_TESTBENCH_NAME.vt_event1);在整个case的执行过程中,只要.c触发event1,就执行 ...

  2. zw版【转发·台湾nvp系列Delphi例程】HALCON InpaintingCt2

    zw版[转发·台湾nvp系列Delphi例程]HALCON InpaintingCt2 unit Unit1;interfaceuses Windows, Messages, SysUtils, Va ...

  3. iOS证书申请详细流程

    一.事前准备 1.1 准备苹果帐号 首先您需要有一个苹果的开发者帐号,一个mac系统.如果没有帐号可以打开申请加入苹果的开发者计划.如何申请网上有详细的介绍,在此不多做介绍. 如果您已经有了一个帐号, ...

  4. 在Ubuntu Kylin下安装QQ教程

    下载: 下载地址:http://www.ubuntukylin.com/application/show.php?lang=cn&id=279 下载后解压得到wine-qqintl文件夹,里面 ...

  5. Linux查看CPU和内存使用情况【转】

    转自:http://www.cnblogs.com/xd502djj/archive/2011/03/01/1968041.html 在系统维护的过程中,随时可能有需要查看 CPU 使用率,并根据相应 ...

  6. JavaEE基础(二十六)/网络

    1.网络编程(网络编程概述) A:计算机网络 是指将地理位置不同的具有独立功能的多台计算机及其外部设备,通过通信线路连接起来,在网络操作系统,网络管理软件及网络通信协议的管理和协调下,实现资源共享和信 ...

  7. 使用radioGroup的时候,每个radioButton的状态选择器要使用 state_checked=""属性,不能使用selected

    使用radioGroup的时候,每个radioButton的状态选择器要使用 state_checked=""属性,不能使用selected

  8. 6.shap以及selector的使用

    功能:相当于自定义一个模板 首先,要新建一个drawble文件夹 然后,再新建一个XML文件 在<shap></shap>中写内容 <corners/>圆角 < ...

  9. 关于android中Bundle的使用

      1.Android using Bundle for sharing variables 注:android中使用Bundle来共享变量,下例中Activity1和Activity2通过bundl ...

  10. 给用户添加sudo权限

    centos中默认创建的新用户是没有sudo权限的. 在文件/etc/sudoers中添加即可: ## Allow root to run any commands anywhere root ALL ...