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. ubuntu_linux /boot/grub/grub.conf

    ==========================================UBUNTU  /boot/grub/grub.conf文件============================ ...

  2. Eclipse集成Maven的Web工程demo(独立及Maven集成tomcat)

    用到的工具JDK1.8Eclipse Luna j2eeEclipse 集成的Mavetomcat7 (集成在xampp中的独立web服务器,或者通过Maven plugin集成web服务器) 步骤如 ...

  3. 【Mail.Ru Cup 2018 Round 2 A】 Metro

    [链接] 我是链接,点我呀:) [题意] [题解] 1:一直往右走的情况. 2:中间某个地方中转 (不会出现超过1次的转弯. (如果超过了和1次是等价的 [代码] #include <bits/ ...

  4. [Cogs727] [网络流24题#2] 太空飞行计划 [网络流,最小割]

    建图:源点—(w[i])—>实验—(∞)—>仪器—(cost[i])—>汇点, 如果该实验造成收益,则仪器到汇点的边在最小割中, 如果该实验造成损失,则源点到实验的边在最小割中, 故 ...

  5. noip2013 Day2 T2 花匠 解题报告

    题目: 3289 花匠 2013年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目描述 Description 花匠栋栋种了一排花,每株花都有自己的高度.花儿越长越大, ...

  6. iOS:让64位兼容百度地图

    当使用了百度地图sdk的app在64位机中运行时,会出现No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_6 ...

  7. CF #319 div 2 E

    在一个边长为10^6正方形中,可以把它x轴分段,分成1000段.奇数的时候由底往上扫描,偶数的时候由上往下扫描.估计一下这个最长的长度,首先,我们知道有10^6个点,则y邮方向最多移动10^3*10^ ...

  8. maven出现不再支持源选项 1.5。请使用 1.6 或更高版本

    maven出现不再支持源选项 1.5.请使用 1.6 或更高版本 学习了:http://blog.csdn.net/sosous/article/details/78312867 错误: [ERROR ...

  9. 臣妾做不到啊---记团队内首次尝试HOLACRACY管理会议

    "易穷则变,变则通.通则久". --<系辞传>下篇的第二章 实践敏捷方法接近两年,瓶颈效应逐渐显现.计穷力竭之时.有幸了解到HOLACRACY.购买了市面上唯一一本中文 ...

  10. C#和JAVA中编写事务代码

    C#  DAL层代码,运行多条增删改,使用事务操作: /// <summary> /// 运行 多条增删改 (非查询语句) /// </summary> /// <par ...