Pagini recente » Cod sursa (job #3234082) | Cod sursa (job #3216510) | Cod sursa (job #385205)
Cod sursa(job #385205)
type lol=array [1..16,1..16] of longint;
ac=array [1..16] of -1..1;
var n,m,i,j:longint;
maxs:longint;
a:lol;
sol:ac;
f:text;
procedure ev;
var i,j,s,sc:longint;
begin
s:=0;
for i:=1 to m do
begin
sc:=a[1,i];
for j:=2 to n do
sc:=sc+sol[j]*a[j,i];
s:=s+abs(sc);
end;
if maxs<s then maxs:=s;
end;
procedure flip(p:integer);
begin
sol[p]:=1;
if p=n then ev
else flip(p+1);
sol[p]:=-1;
if p=n then ev
else flip(p+1);
end;
begin
assign(f,'flip.in');reset(f);
readln(f,n,m);
for i:=1 to n do
begin
for j:=1 to m do
read (f,a[i,j]);
readln(f);
end;
close(f);
maxs:=0;
flip(1);
assign(f,'flip.out');rewrite(f);
write(f,maxs);
close(f);
end.