Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program vodaD;
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- var
- n, m, i, max, rez: integer;
- a: array [1 .. 100000] of integer;
- function jaga(a: integer): integer;
- begin
- result := trunc(a div 10);
- end;
- function getmax: integer;
- var
- i: integer;
- begin
- result := 1;
- for i := 2 to n do
- if a[i] > a[result] then
- result := i;
- end;
- begin
- reset(input, 'input.txt');
- rewrite(output, 'output.txt');
- readln(n, m);
- max := 1;
- read(a[1]);
- for i := 2 to n do
- begin
- read(a[i]);
- if a[i] > a[max] then
- max := i;
- end;
- while m > 0 do
- begin
- if a[max] >= 20 then
- begin
- while a[max] >= 20 do
- a[max] := jaga(a[max]);
- end
- else
- a[max] := jaga(a[max]);
- dec(m);
- if m > 0 then
- max := getmax;
- end;
- rez:=0;
- for i := 1 to n do
- inc(rez,a[i]);
- writeln(rez);
- end.
Add Comment
Please, Sign In to add comment