Pagini recente » Cod sursa (job #2569629) | Cod sursa (job #3255690) | Cod sursa (job #1120389) | Cod sursa (job #2377348) | Cod sursa (job #1040780)
var a:array[1..16,1..16] of integer;
q:array[1..32] of integer;
i,j,n,m,l,c,s,max,t,k:integer;
f,g:text;
begin
assign(f,'flip.in');reset(f);
assign(g,'flip.out');rewrite(g);
readln(f,n,m);
max:=0;
for i:=1 to n do
begin
for j:=1 to m do
read(f,a[i,j]);
readln(f);
end;
t:=m+n;s:=0;max:=0;
for i:=1 to (1 shl t)-1 do
begin
for j:=0 to t do
if (1 shl j) and i >0 then q[j+1]:=1 else q[j+1]:=0;
for l:=1 to n do
for c:=1 to m do
if (q[l]=1) and (q[c+n]=1) then s:=s+a[l,c]
else if (q[l]=0) and (q[c+n]=0) then s:=s+a[l,c]
else s:=s-a[l,c];
if abs(s)>max then max:=abs(s);
s:=0
end;
writeln(g,max);
close(f);close(g);
end.