Pagini recente » Cod sursa (job #2308719) | Cod sursa (job #1525632) | Cod sursa (job #2289566) | Cod sursa (job #1782663) | Cod sursa (job #524268)
Cod sursa(job #524268)
var b:array[1..16,1..16]of longint;
a:array[1..32]of shortint;
n,m:byte; max:longint; f:text;
procedure citire;
var i,j:byte; f:text;
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,b[i,j]);
readln(f);
end;
close(f);
end;
function calcul:longint;
var i,j:byte;k:longint;
begin
k:=0;
for i:=1 to n do
for j:=1 to m do k:=k+b[i,j]*a[i]*a[n+j];
calcul:=k;
end;
procedure gen_bin(p:byte);
var k:longint;
begin
if p>n+m then
begin
k:=calcul;
if k>max then max:=k;
end else begin
a[p]:=-1; gen_bin(p+1);
a[p]:=1; gen_bin(p+1);
end;
end;
begin
max:=0;
citire;
gen_bin(1);
assign(f,'flip.out');
rewrite(f);
writeln(f,max);
close(f);
end.