5 heap
:array [0..maxn
] of longint;
9 procedure swap(var p
,q
:longint);
16 procedure up(i
:longint);
19 if heap
[i
]<heap
[i
shr 1] then
21 swap(heap
[i
],heap
[i
shr 1]);
26 procedure down(i
:longint);
33 if (j
+1<=n
) and (heap
[j
+1]<heap
[j
]) then inc(j
);
34 if heap
[i
]>heap
[j
] then
36 swap(heap
[i
],heap
[j
]);
41 function delmin
:longint;
52 for i
:=1 to m
do read(heap
[i
]);
53 for i
:=m
shr 1 downto 1 do down(i
);