Problem description

Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.

There are n columns of toy cubes in the box arranged in a line. The i-th column contains ai cubes. At first, the gravity in the box is pulling the cubes downwards. When Chris switches the gravity, it begins to pull all the cubes to the right side of the box. The figure shows the initial and final configurations of the cubes in the box: the cubes that have changed their position are highlighted with orange.

Given the initial configuration of the toy cubes in the box, find the amounts of cubes in each of the n columns after the gravity switch!

Input

The first line of input contains an integer n (1 ≤ n ≤ 100), the number of the columns in the box. The next line contains n space-separated integer numbers. The i-th number ai (1 ≤ ai ≤ 100) denotes the number of cubes in the i-th column.

Output

Output n integer numbers separated by spaces, where the i-th number is the amount of cubes in the i-th column after the gravity switch.

Examples

Input

4
3 2 1 2

Output

1 2 2 3 

Input

3
2 3 8

Output

2 3 8 

Note

The first example case is shown on the figure. The top cube of the first column falls to the top of the last column; the top cube of the second column falls to the top of the third column; the middle cube of the first column falls to the top of the second column.

In the second example case the gravity switch does not change the heights of the columns.

解题思路:升序排列并输出,水过!

AC代码:

 #include<bits/stdc++.h>
using namespace std;
int main(){
int n,a[];
cin>>n;
for(int i=;i<n;++i)cin>>a[i];
sort(a,a+n);
for(int i=;i<n;++i)
cout<<a[i]<<(i==n-?"\n":" ");
return ;
}

C - Gravity Flip的更多相关文章

  1. codeforces Gravity Flip 题解

    版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/,未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...

  2. Codeforces 238 div2 A. Gravity Flip

    题目链接:http://codeforces.com/contest/405/problem/A 解题报告:有n列箱子竖直放置,每列箱子上都有数量不等的箱子,这些箱子之间没有固定,当重力方向改为平行向 ...

  3. CodeForces - 405A

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

  4. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  5. [LeetCode] Flip Game 翻转游戏之二

    You are playing the following Flip Game with your friend: Given a string that contains only these tw ...

  6. [LeetCode] Flip Game 翻转游戏

    You are playing the following Flip Game with your friend: Given a string that contains only these tw ...

  7. poj Flip Game 1753 (枚举)

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 27005   Accepted: 11694 Descr ...

  8. POJ1753 Flip Game(bfs、枚举)

    链接:http://poj.org/problem?id=1753 Flip Game Description Flip game is played on a rectangular 4x4 fie ...

  9. Android之layout_gravity与gravity解析

    相信layout_gravity和gravity这两个属性一直困扰着很多人,很多初学者都分不清这两个属性有什么区别,以及怎样区分它们.它们中,有一个表示的是一个控件在父布局中的位置,而另一个表示的是一 ...

随机推荐

  1. c++ map: 当map的value是void*指针

    #include <iostream> #include <map> #include <vector> using namespace std; //key is ...

  2. 计蒜客 劫富济贫 (Trie树)

    链接 : Here! 思路 : Trie树裸题, 由开始给出的名字建一棵字典树, 然后每次查询一下抢♂劫的人名是否在字典树中, 复杂度也不清楚是多少, 反正是没给出 $M$ 的范围, 开始时用 $ha ...

  3. 洛谷——P1966 火柴排队&&P1774 最接近神的人_NOI导刊2010提高(02)

    P1966 火柴排队 这题贪心显然,即将两序列中第k大的数的位置保持一致,证明略: 树状数组求逆序对啦 浅谈树状数组求逆序对及离散化的几种方式及应用 方法:从前向后每次将数插入到bit(树状数组)中, ...

  4. 第十六节:pandas之日期时间

    Pandas日期功能扩展了时间序列,在财务数据分析中起主要作用.

  5. Django-cookie与session操作

    添加cookie: def login(req): if req.method=="POST": uf = UserInfoForm(req.POST) if uf.is_vali ...

  6. 多层gmetad配置

    经实验表明: ①多层gmetad与ganglia版本无关,且可以多版本兼容 ②多层gmetad只有最底层gmetad能保存详细指标,非底层gmetad收集到的都只能是summary信息,当然也许我配置 ...

  7. 如何应对SHA-1加密算法升级为SHA-256

    经过权威机构证实,sha1加密算法的不安全性越来越高,sha指纹造假成本越来越低,随即微软.谷歌等IT巨头相继发布弃用sha1加密算法声明,第三方认证机构自2016年1月1日起,将全面停止签发SHA1 ...

  8. spring配置Converter、Formatter日期转换器

    最近有点恶补spring的嫌疑,然后学了一点知识点纪录在此. 往往在项目中我们会遇到前端页面输入一个日期类型的字符串传递到后端后我们需要去做转换.甚至在传递的过程中就会报错. Spring有一个一劳永 ...

  9. noip模拟赛 SAC E#1 - 一道中档题 Factorial

    题目背景 数据已修改 SOL君(炉石主播)和SOL菌(完美信息教室讲师)是好朋友. 题目描述 SOL君很喜欢阶乘.而SOL菌很喜欢研究进制. 这一天,SOL君跟SOL菌炫技,随口算出了n的阶乘. SO ...

  10. 一个手机图表(echarts)折线图的封装

    //定义一组颜色值,按顺序取出 var colorGroup = ["#6ca3c4","#76bfa3","#ea8f7a"," ...