Pagini recente » Cod sursa (job #2623749) | Cod sursa (job #143708) | Cod sursa (job #2277646) | Cod sursa (job #2890692) | Cod sursa (job #573192)
Cod sursa(job #573192)
var
a:array[1..16,1..16] of longint;
n,m,i,j,k:integer;
suma,fin,s,ps:longint;
begin
assign(input,'flip.in');reset(input);
assign(output,'flip.out');rewrite(output);
readln(n,m);
fillchar(a,sizeof(a),0);
for i:=1 to n do
for j:=1 to m do
read(a[i][j]);
fin:= 1 shl m;
suma:=0;
for k:=0 to fin do begin
s:=0;
for i:=1 to n do begin
ps:=0;
for j:=1 to m do begin
if k and (1 shl j) > 0 then ps:=ps + (-1) * a[i][j] else ps:=ps+a[i][j];
end;
if ps < 0 then s:=s-ps else s:=s+ps;
end;
if s > suma then suma:=s;
end;
writeln(suma);
end.