Pagini recente » Cod sursa (job #3178330) | Cod sursa (job #2490424) | Cod sursa (job #3121513) | Cod sursa (job #3153750) | Cod sursa (job #1996458)
Program Flip;
type max =1..16;
tab = array[max,max] of -1000000..1000000;
var n,m,i,j:max;
fl:tab;
a,s:longint;
procedure SRand(var fl: tab; r:max);
var i: max;
begin
for i:=1 to m do
fl[r,i]:= -fl[r,i];
end;
procedure SCol(var fl: tab; r:max);
var i: max;
begin
for i:=1 to n do
fl[i,r]:= -fl[i,r];
end;
procedure Evaluare;
var i,j:max;
begin
for i:= 1 to n do
for j:=1 to m do
s:= s+fl[i,j];
end;
begin
readln(n,m);
for i:=1 to n do begin
for j:=1 to m do
read(fl[i,j]);
readln;
end;
for i:=1 to n do begin
a:=0;
for j:=1 to m do
a:= a + fl[i,j];
if a<0 then SRand(fl,i);
end;
for j:=1 to m do begin
a:=0;
for i:=1 to n do
a:= a + fl[i,j];
if a<0 then SCol(fl,j);
end;
Evaluare;
writeln(s);
readln;
end.