MERGSORT - Mergesort

no tags 

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

hide comments
singhks: 2018-05-29 08:49:47

I used mergesort and used " while( scanf("%d",&n) != EOF ) { a[i++] = n ; } " to take input
still getting TLE. can anyone help

teracoder: 2016-11-09 16:44:40

Can I use my own QuickSort?

darkhire21: 2015-08-19 20:53:00

Those who using EOF carefully It do not work on console . It work with file input like online judges like spoj .

Last edit: 2015-11-20 14:35:11
Rafiq: 2014-12-10 13:28:34

Runtime error why ?

TIGM: 2014-06-15 19:24:17

good for learning merge sort :)

Andi: 2013-11-18 04:48:07

Nevermind, how u said, u get it in the string.

Last edit: 2013-11-18 05:07:08
Ouditchya Sinha: 2013-04-25 12:28:06

@bansal, use
i = 0 ;
while( scanf("%d",&n) != EOF ) { a[i++] = n ; }

Naveen Agarwal: 2012-09-07 21:22:11

http://filecopter.net/files/m59NHT1347052899.html

Breno: 2012-09-04 19:46:58

you have to receive the numbers into a string

bansal: 2012-08-28 20:30:17

how will i know how many numbers are there ?????


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