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 32bit 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
hide comments
bansal:
20120828 20:30:17
how will i know how many numbers are there ????? 

Felipe Lima [UFS]:
20120604 23:48:52
Anurag, the input is finished with end of file 

Anurag Atri:
20110314 03:19:06
how will i know how many numbers are there ?Or how can i know the end of input . 

যোবায়ের:
20090923 17:23:27
Number of inversions can also be counted by quicksort, but a bit tedious.


David Pìgøímek (Davpe):
20090308 18:49:33
I think, this problem is really good, finally something, that forces me to program MergeSort ;). But it should be in tutorial, so no one could bother cheating. 

.:: Pratik ::.:
20091103 13:49:41
why is SPOJ going down these days? 

Brian Bi:
20090302 21:35:19
How about counting the number of inversions in the sequence? It's doable with mergesort but not any other sort (I think), and is an intrinsic property of the sequence, whereas the left/right switch count seems a bit... ad hoc. For example, given the sequence 3 1 2, the number of switches depends on whether you split it as 3  1 2 or 3 1  2. Last edit: 20090302 21:35:19 

Navin Parakkal:
20090301 01:43:42
can the author really look at the source ? 

Srinivas Iyengar:
20090228 07:49:45
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. 

MiorelLucian Palii:
20090228 06:17:29
By the way, you can see my source, but I can obfuscate it. ;) 
Added by:  Nikola P Borisov 
Date:  20081117 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 