Pagini recente » Concursul National de Soft Grigore Moisil Lugoj, Clasament 11-12 | Cod sursa (job #171575) | Cod sursa (job #2934969) | Cod sursa (job #1536820) | Cod sursa (job #274568)
Cod sursa(job #274568)
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.