Pagini recente » Cod sursa (job #2391749) | Profil Lasoloz | Cod sursa (job #1250112) | Rating Veres Andrei (Verigul1237) | Cod sursa (job #276547)
Cod sursa(job #276547)
var m,n,i,j,k,ck,suma,sumal,max,t:longint;
ca,a:array[1..16,1..16]of longint;
f:array[1..16] of byte;
begin
assign(input,'flip.in');reset(input);
assign(output,'flip.out');rewrite(output);
readln(n,m);
for i:=1 to n do begin
for j:=1 to m do read(a[i,j]);
readln;
end;
t:=1 shl m; max:=0;
for k:=0 to t-1 do begin
ck:=k;
for i:=1 to m do begin f[i]:=ck mod 2;ck:=ck div 2;end;
ca:=a;
for i:=1 to n do
for j:=1 to m do
if f[i]=0 then ca[i,j]:=-ca[i,j];
suma:=0;
for i:=1 to n do begin
sumal:=0;
for j:=1 to m do sumal:=sumal+ca[i,j];
suma:=suma+abs(sumal);
end;
if suma>max then max:=suma;
end;
write(max);
close(input);close(output);
end.