Pagini recente » Cod sursa (job #1859873) | Cod sursa (job #687840) | Cod sursa (job #1756636) | Cod sursa (job #2716489) | Cod sursa (job #124371)
Cod sursa(job #124371)
var n,m,i,j,k,s,t,smax:longint;
a:array[1..16,1..16] Of longint;
f,g:text;
begin
assign(f,'flip.in');
reset(f);
for i:=1 to n do
for j:=1 to m do
read(f,a[i,j]);
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 (1shl (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 smax<s then smax:=s;
end;
close(f);
assign(g,'flip.out');
rewrite(g);
writeln(g,smax);
close(f);
end.