Pagini recente » Cod sursa (job #2591767) | Cod sursa (job #2087999) | Cod sursa (job #1336457) | Cod sursa (job #2151105) | Cod sursa (job #152725)
Cod sursa(job #152725)
var i,j,k,m,n,s,smax,j1,x:longint;
a:array[1..16,1..16] of longint;
f,g:text;
begin
assign(f,'flip.in'); reset(f);
read(f,n); readln(f,m);
for i:=1 to n do
for j:=1 to m do
read(f,a[i,j]);
close(f);
smax:=0;
j1:=1 shl m;
j1:=j1-1;
for k:=0 to j1 do begin
s:=0;
for i:=1 to n do begin
x:=0;
for j:=1 to m do if k and (1 shl (j-1))>0 then x:=x-a[i,j]
else x:=x+a[i,j];
if x<0 then s:=s-x else s:=s+x;
end;
if s>smax then smax:=s;
end;
assign(g,'flip.out');
rewrite(g);
writeln(g,smax);
close(g);
end.