MERGSORT - Mergesort

Simple. Sort the numbers on the standard input using the merge sort algorithm. Don't try to cheat by just calling your build in functions... I can see your source.

Input

On the standard input you will receive N (1 <= N <= 100000). Each number will fit in 32-bit integer

Output

Output the same integers in a sorted manner. Smallest to largest.

Example

Input:
7 3 2 5 4 3

Output:
2 3 3 4 5 7

Added by:Nikola P Borisov
Date:2008-11-17
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET

hide comments
2009-03-01 01:43:42 Navin Parakkal
can the author really look at the source ?
2009-02-28 07:49:45 Srinivas Iyengar
Well I guess you have a valid Point. The Author should have asked about the number of swaps or something that was solely related to MergeSort.
2009-02-28 06:17:29 Miorel-Lucian Palii
By the way, you can see my source, but I can obfuscate it. ;)
2009-02-28 06:16:53 Miorel-Lucian Palii
As far as I'm concerned, any solution that can get AC is correct. And this holds not just on SPOJ but any programming contest/judge. That's because it's impractical to have humans review every solution manually. It's up to the problem author to craft a problem that can only be solved by the desired algorithm.
2009-02-28 05:52:29 Srinivas Iyengar
However You Need to be true to yourself at times.You may use Function Calls sort or qsort but then Does it serve the Purpose is the Million-Dollar Question that you need to ask yourself.
2009-02-28 05:45:08 Miorel-Lucian Palii
It's not feasible for you to manually ensure that submissions are actually implementing merge sort.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.