eolymp
bolt
Try our new interface for solving problems
Problems

Max-heap

Max-heap

Given array of integers. Rearrange its elements so that to get a \textbf{max-heap}. \InputFile First line contains number of elements $n~(n \le 1000)$. Second line contains $n$ integers, no more than $10^6$ by absolute value. \OutputFile Print array that corresponds to max-heap. \includegraphics{https://static.e-olymp.com/content/94/94b59391780652167dd211f1a56ef2f14d2f7ffd.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
6
5 3 2 7 1 10
Output example #1
10 7 5 3 1 2 
Author Mykhailo Medvediev