если массив заполняется случайными числами , то
var
mas: array[0..31]of word;
a, b, c: integer;
begin
b := 10000;
c := 10000;
for a := 0 to 29 do
begin
mas[a] := random(9999) + 1;
if mas[a] mod 2 = 0 then begin if mas[a] < b then b := mas[a]; mas[30] := mas[30] + 1; end;
if mas[a] mod 2 = 1 then begin if mas[a] < c then c := mas[a]; mas[31] := mas[31] + 1; end;
end;
if mas[30] = 0 then b := 0;
if mas[31] = 0 then c := 0;
for a := 0 to 29 do begin if mas[a] > c + b then mas[a] := mas[a] - c - b; writeln(mas[a]); end
end.
если массив заполняется вручную , то
label o;
var
mas: array[0..31]of word;
a, b, c: integer;
begin
b := 10000;
c := 10000;
for a := 0 to 29 do
begin
o:
read(mas[a]);
if (mas[a] < 1)or(mas[a] > 10000) then goto o;
if mas[a] mod 2 = 0 then begin if mas[a] < b then b := mas[a]; mas[30] := mas[30] + 1; end;
if mas[a] mod 2 = 1 then begin if mas[a] < c then c := mas[a]; mas[31] := mas[31] + 1; end;
end;
if mas[30] = 0 then b := 0;
if mas[31] = 0 then c := 0;
for a := 0 to 29 do begin if mas[a] > c + b then mas[a] := mas[a] - c - b; writeln(mas[a]); end
end.