Pagini recente » Cod sursa (job #3292166) | Cod sursa (job #37714) | newcomers_6 | gonathan | Cod sursa (job #589464)
Cod sursa(job #589464)
Program p1;
var a : array[1..100,1..100] of longint;
n,m,max : longint;
Procedure citire;
var fin : text;
i,j : integer;
begin
assign(fin,'flip.in');
reset(fin);
readln(fin,n,m);
for i:=1 to n do
for j:=1 to m do
read(fin,a[i,j]);
close(fin);
end;
Procedure calc;
var s,i,j,t,k : longint;
fout : text;
begin
for i:=1 to (1 shl m) 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 t:=t-a[k,j] else
t:=t+a[k,j];
if t<-t then s:=s-t else s:=s+t;
end;
if s>max then max:=s;
end;
assign(fout,'flip.out');
rewrite(fout);
writeln(fout,max);
close(fout);
end;
begin
citire;
calc;
end.