Advertisement
MadCortez

Untitled

Nov 4th, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.60 KB | None | 0 0
  1. var
  2.    a, b: array[1..10000] of Integer;
  3.    min, max, i, n, k: Longint;
  4. begin
  5.    min := 99999999;
  6.    readln(n);
  7.    for i := 1 to n do
  8.    begin
  9.       read(a[i]);
  10.       inc(b[a[i]]);
  11.       if a[i] < min then
  12.          min := a[i];
  13.       if a[i] > max then
  14.          max := a[i];
  15.    end;
  16.    k := 5;
  17.    while k > 0 do
  18.    begin
  19.       for i := min to max do
  20.       while (b[i] > 0) and (k > 0) do
  21.       begin
  22.          dec(b[i]);
  23.          dec(k);
  24.       end;
  25.    end;
  26.    for i := 1 to n do
  27.       if b[a[i]] > 0 then
  28.       begin
  29.          write(a[i],' ');
  30.          dec(b[a[i]]);
  31.       end;
  32. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement