Moze nekoj da se obide da mi ja najde greskata? Resenieto mi raboti samo na 4 test slucai.
program izbori;
var n:1..50;
g:array[1..50] of 1..100;
min,p,i,j:longint;
begin
readln(n);
for i:=1 to n do
readln(g[i]);
for i:=2 to n do
for j:=i+1 to n do
if g[j]>g[i] then
begin
p:=g[i];
g[i]:=g[j];
g[j]:=p;
end;
min:=0;
i:=2;
while g[i]>=g[1] do
begin
g[i]:=g[i]-1;
g[1]:=g[1]+1;
if g[i]<g[i+1] then i:=i+1;
min:=min+1;
end;
write(min);
readln;
end.
This message was edited 1 time. Last update was at 29/03/2012 23:52:54
|