АВТ
Language:

Remote Training on Programming

Problems On-line status Contests FAQ
For authors:
Register  ||  Login
 
Hello, Guest! Login or register.

293. Heap Construction

Time Limit: 1 seconds
Memory Limit:64000KB
Points:5
View Problem Statistics Submit Problem added Undefined

Написать алгоритм формирования невозрастающей пирамиды из последовательности N чисел так, как это делается в 1-й части алгоритма пирамидальной сортировки (двигаясь от середины массива к началу, выполняем «погружение» очередного элемента)

Input

В первой строке целое число N – количество элементов. В следующей строке содержится исходная последовательность целых чисел, разделенных пробелами (не более 100 элементов).

Output

Результирующая последовательность, образующая пирамиду.

Sample

InputOutput
5
1 2 3 4 5
5 4 3 1 2

Автор: Хлупин Д.Н.


View Problem Statistics Submit Author/source:
Sorted Problems / Sorting and Searching /
985. Binary Search in Sorted Array 293. 4. QuickSort
Educational Courses / Data Structures and Algorithms / Student's Problems - old groups /
370. Heap 293. 299. Maximal flow 292. One-way Racing 301. Red-Black Tree
We can all benefit by doing occasional "toy" programs, when artificial restrictions are set up, so that we are forced to push our abilities to the limit. The art of tackling miniproblems with all our energy will sharpen our talents for the real problems. Donald E. Knuth.
time generating 0.109 sec.
© Copyright VSTU, AVT, Nosov D.A.