Pagini recente » Cod sursa (job #1199830) | Cod sursa (job #1019691) | Cod sursa (job #2281415) | Cod sursa (job #2180125) | Cod sursa (job #1169915)
program flip;
var a:array[1..16,1..16] of longint;
n,m,i,j,k,sum,c,bestsum:longint;
begin
assign(input,'flip.in');
reset(input);
assign(output,'flip.out');
rewrite(output);
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 n do
begin
sum:=0;
for j:=1 to m do
begin
c:=0; {c- suma pe coloana}
for k:=1 to n do
if i and (1 shl k)=0 then c:=c+a[k,j]
else c:=c-a[k,j];
if c<0 then c:=-c;;
sum:=sum+c;
end;
if sum>bestsum then bestsum:=sum;
end;
write(bestsum);
close(output);
end.