SlepoiKrot

Untitled

Dec 31st, 2017
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program sweets;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7. var
  8.   n, m, min, i: integer;
  9.   a: array [1..10001] of integer;
  10. begin
  11.   readln (n, m);
  12.   min := n + 1;
  13.   a[min] := 30001;
  14.   for i := 1 to n do begin
  15.     readln (a[i]);
  16.   end;
  17.   while (m <> 0) do begin
  18.     for i := 1 to n do begin
  19.       if (a[i] <= a[min]) then
  20.       min := i;
  21.     end;
  22.       m := m - 1;
  23.       inc (a[min]);
  24.   end;
  25.   min := 1000000;
  26.   for i := 1 to n do begin
  27.     if (a[i] < min) then
  28.       min := a[i];
  29.   end;
  30.   writeln (min);
  31.   readln;
  32.   readln;
  33. end.
RAW Paste Data