Pagini recente » Pitici2 | Cod sursa (job #958056) | Cod sursa (job #93856) | Diferente pentru implica-te/extinde-arhiva intre reviziile 18 si 19 | Cod sursa (job #20198)
Cod sursa(job #20198)
var n,m,i,j,k,s,t,smax:longint;
a:array[1..16,1..16]of longint;
begin
assign(input,'flip.in');
reset(input);
readln(n,m);
for i:=1 to n do
for j:=1 to m do read(a[i,j]);
for i:=0 to(1 shl m)-1 do begin
s:=0;
for k:=1 to n do begin
t:=0;
for j:=1 to m do
if i and(1 shl(j-1))>0 then inc(t,-a[k,j]) else inc(t,a[k,j]);
if t<-t then inc(s,-t) else inc(s,t);
end;
if smax<s then smax:=s;
end;
assign(output,'flip.out');
rewrite(output);
writeln(smax);
end.