Pagini recente » Cod sursa (job #485400) | Cod sursa (job #1973247) | Cod sursa (job #3211705) | Cod sursa (job #2636039) | Cod sursa (job #301784)
Cod sursa(job #301784)
var n,m,i,j,k,s,smax,q:longint;
t:array[1..16,1..16]of longint;
f,g:text;
begin
assign(f,'flip.in');
assign(g,'flip.out');
reset(f); rewrite(g);
readln(f,n,m);
for i:=1 to n do for j:=1 to m do read(f,t[i,j]);
for i:=1 to (1 shl m)-1 do
begin
s:=0;
for k:=1 to n do
begin
q:=0;
for j:=1 to m do
if i and (1 shl (j-1))>0 then inc(q,-t[k,j])
else inc(q,t[k,j]);
if q<-q then inc(s,-t)
else inc(s,t);
end;
if smax<s then smax:=s;
end;
writeln(g,smax);
close(f);
close(g);
end.