Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- n, i: integer;
- b, a: array [-100000..100000] of integer;
- procedure push(a, v: integer);
- begin
- if (b[v] = 0) then b[v] := a
- else
- begin
- if(a<b[v]) then push(a, v * 2)
- else push(a, v * 2 + 1);
- end;
- end;
- procedure outp(v: integer);
- begin
- if(b[v * 2 + 1] <> 0) then
- outp(v*2+1);
- if(b[v*2] <> 0) then
- outp(v*2);
- write (b[v]);
- if(v <> 1) then
- write(' ');
- end;
- begin
- readln(n);
- for i := -100000 to 100000 do
- b[i] := 0;
- for i := 1 to n do
- read(a[i]);
- for i := n downto 1 do
- push(a[i], 1);
- outp(1);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement