Pagini recente » Istoria paginii runda/lux/clasament | Cod sursa (job #374437) | Cod sursa (job #774659) | Cod sursa (job #2837429) | Cod sursa (job #385168)
Cod sursa(job #385168)
type ma=array [1..16,1..16] of longint;
ta=array [1..16] of -1..1;
var n,m,i,j:longint;
maxs:longint;
a:ma;
sol:ta;
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.