Pagini recente » Cod sursa (job #714486) | Cod sursa (job #2826243) | Cod sursa (job #1743169) | Cod sursa (job #1875218) | Cod sursa (job #308201)
Cod sursa(job #308201)
const d:array[1..2] of integer=(1,-1);
var f,g:text;
sol:array[0..17] of longint;
a:array[0..17,0..17] of longint;
n,m,i,j,suma:longint;
procedure calcul;
var i,j,s1,s2:longint;
begin
s1:=0;
for j:=1 to m do begin
s2:=0;
for i:=1 to n do
s2:=s2+sol[i]*a[i,j];
s1:=s1+abs(s2);
end;
if suma<s1 then suma:=s1;
end;
procedure back(k:longint);
var i:longint;
begin
if k>n then begin
calcul;
end
else
for i:=1 to 2 do begin
sol[k]:=d[i];
back(k+1);
end;
end;
begin
assign(f,'flip.in');reset(f);
assign(g,'flip.out');rewrite(g);
read(f,n,m);
for i:=1 to n do
for j:=1 to m do
read(f,a[i,j]);
suma:=0;
back(1);
writeln(g,suma);
close(f);
close(g);
end.