Pagini recente » Cod sursa (job #749949) | Cod sursa (job #1338979) | Cod sursa (job #1057392) | Cod sursa (job #274734) | Cod sursa (job #150749)
Cod sursa(job #150749)
program infoarena_flip;
var i,j,k,k1,k2,m,n,s,smax,i1,j1,x1,x2:longint;
a:array[1..16,1..16] of longint;
begin
assign(input,'flip.in');
reset(input);
read(n);readln(m);
for i:=1 to n do
for j:=1 to m do
read(a[i,j]);
close(input);
smax:=0;
j1:=1 shl m;
j1:=j1-1;
for k2:=0 to j1 do
begin
s:=0;
for i:=1 to n do
begin
x1:=0;
for j:=1 to m do
if k2 and (1 shl (j-1))>0 then x1:=x1-a[i,j]
else x1:=x1+a[i,j];
if x1<0 then s:=s-x1
else s:=s+x1;
end;
if s>smax then smax:=s;
end;
assign(output,'flip.out');
rewrite(output);
writeln(smax);
close(output);
end.