about summary refs log tree commit diff
path: root/others/volume1/016.pas
blob: 510a0294a78b5fb09df2b3ca4b6eb8c6b1283741 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var
  s, z: ansistring;
  i, j, k: int16;

begin
  readln(s);
  readln(k);
  setlength(z, length(s));
  i := 0;
  j := 0;
  repeat
    inc(i);
    while (j > 0) and
          (k > 0) and
          (s[i] > z[j]) do
      begin
        dec(j);
        dec(k)
      end;
    inc(j);
    z[j] := s[i]
  until i = length(s);
  writeln(z)
end.