Pagini recente » Cod sursa (job #2229634) | Cod sursa (job #2219773) | Cod sursa (job #566809) | Cod sursa (job #1669265) | Cod sursa (job #391288)
Cod sursa(job #391288)
program flip;
var a:array[1..16,1..16]of longint;
y:array[1..16]of -1..1;
n,m,i,j:byte;
s:longint;
procedure caut;
var ss,aux:longint;
i,j:byte;
begin
ss:=0;
for i:=1 to n do begin
aux:=0;
for j:=1 to m do aux:=aux+(y[j]*a[i,j]);
ss:=ss+abs(aux);
end;
if ss>s then s:=ss;
end;
procedure go(k:byte);
begin
y[k]:=1;
if k=m then caut
else go(k+1);
y[k]:=-1;
if k=m then caut
else go(k+1);
end;
begin
assign(input,'flip.in'); reset(input);
read(n,m);
for i:=1 to n do
for j:=1 to m do read(a[i,j]);
close(input);
s:=(-1)*maxlongint;
go(1);
assign(output,'flip.out'); rewrite(output);
write(s);
close(output);
end.