Pagini recente » Cod sursa (job #1912339) | Cod sursa (job #1839222) | Cod sursa (job #20516) | Cod sursa (job #2253997) | Cod sursa (job #2183)
Cod sursa(job #2183)
var n,m,i,j,k,s,t,max:longint;f:text;
a:array[1..16,1..16] of longint;
begin
assign(f,'flip.in');reset(f);
readln(f,n,m);
for i:=1 to n do begin
for j:=1 to m do read(f,a[i][j]);
readln(f);
end;
close(f);
for i:=0 to (1 shl m)-1 do
begin
s:=0;
for k:=1 to n do
begin
t:=0;
for j:=1 to m do
if i and (1 shl(j-1))>0 then inc(t,-a[k][j])
else inc(t,a[k][j]);
if t<-t then inc(s,-t)
else inc(s,t);
end;
if s>max then max:=s;
end;
assign(f,'flip.out');rewrite(f);
writeln(f,max);
close(f);
end.