Pagini recente » Cod sursa (job #3212566) | Cod sursa (job #1062340) | Cod sursa (job #178339) | Cod sursa (job #522541) | Cod sursa (job #1990217)
var a,b,n,i,m,j,x,y:longint;
s:string[20];
t:array[1..20,1..20] of longint;
procedure max(s:string);
var b1,b,i,j:longint;
begin
b1:=0;
for i:=1 to m do
begin
b:=0;
for j:=1 to n do
if s[j]='1' then b:=b-t[j,i] else b:=b+t[j,i];
if -b>b then b:=-b;
b1:=b1+b;
end;
if b1>x then x:=b1;
end;
procedure gen(s:string);
begin
if length(s)<n then begin
gen(s+'0');
gen(s+'1');
end
else max(s);
end;
begin
assign(input,'flip.in');
reset(input);
readln(n,m);
for i:=1 to n do
for j:=1 to m do
begin
read(t[i,j]);
if j=m then readln;
end;
close(input);
s:='';
gen(s);
assign(output,'flip.out');
rewrite(output);
write(x);
close(output);
end.