Pagini recente » Cod sursa (job #3142643) | Cod sursa (job #2590626) | Cod sursa (job #479810) | Cod sursa (job #2172419) | Cod sursa (job #274557)
Cod sursa(job #274557)
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(j-1)>0 then
inc(p,-a[k,j])
else inc(p,a[k,j]);
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.