Pagini recente » Cod sursa (job #2639124) | Cod sursa (job #376706) | Cod sursa (job #1981735) | Cod sursa (job #2970815) | Cod sursa (job #296518)
Cod sursa(job #296518)
var a:array[1..16,1..16] of longint;
n,m:byte;
smax:longint;
f:text;
procedure citire;
var i,j:byte;
begin
assign(f,'flip.in'); reset(f);
readln(f,n,m);
for i:=1 to n do
for j:=1 to m do read(f,a[i,j]);
close(f);
end;
procedure rezolvare;
var i,s,t:longint;
k,j:byte;
begin
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 smax<s then smax:=s;
end;
end;
procedure afisare;
var g:text;
begin
assign(g,'flip.out'); rewrite(g);
writeln(g,smax);
close(g);
end;
begin
citire;
rezolvare;
afisare;
end.