Pagini recente » Cod sursa (job #702133) | Cod sursa (job #2810359) | Cod sursa (job #1177233) | Cod sursa (job #1517115) | Cod sursa (job #524259)
Cod sursa(job #524259)
var t:array[1..16, 1..16] of longint;
a:array[1..100] of shortint;
na,n,m:integer; smax:int64;
procedure init;
var i,j:integer; f:text;
begin
assign(f, 'flip.in');
reset(f);
readln(f,n,m);
na:=n + m;
smax:=-1000000000;
for i:=1 to n do
for j:=1 to m do
read(f, t[i,j]);
close(f);
end;
procedure rez;
var f:text;
begin
assign(f, 'flip.out');
rewrite(f);
write(f, smax);
close(f);
end;
procedure calc;
var i,j:integer; s:int64;
begin
s:=0;
for i:=1 to n do
for j:=1 to m do
s:=s+t[i,j]*a[i]*a[n+j];
if smax<s then smax:=s;
end;
procedure bin(p:integer);
begin
if p>na then calc
else begin
a[p]:=-1; bin(p+1);
a[p]:=1; bin(p+1);
end;
end;
begin
init;
bin(1);
rez;
end.