Pagini recente » Cod sursa (job #1674137) | Cod sursa (job #229933) | Cod sursa (job #3137809) | Cod sursa (job #1211447) | Cod sursa (job #289631)
Cod sursa(job #289631)
program flip;
var i,j,k,p,s,smax,m,n:longint;
a:array[1..16,1..16] of longint;
begin
smax:=0;
assign(input,'flip.in');
reset(input);
read(input,n,m);
for i:=1 to n do
for j:=1 to m do read(input,a[i,j]);
close(input);
for i:=1 to (1 shl m)-1 do begin
s:=0;
for j:=1 to n do begin
p:=0;
for k:=1 to m do
if i and (1 shl(k-1))>0 then
inc(p,-a[j,k])
else inc(p,a[j,k]);
if p<-p then
inc(s,-p)
else inc(s,p);
end;
if s>smax then smax:=s;
end;
assign(output,'flip.out');
rewrite(output);
write(output,smax);
close(output);
end.