Pagini recente » Cod sursa (job #2449280) | Cod sursa (job #1782171) | Cod sursa (job #2858954) | Cod sursa (job #2737271) | Cod sursa (job #525718)
Cod sursa(job #525718)
var a:array[1..100]of integer;
c:array[1..100,1..100]of int64;
n,m:byte; max:int64; f:text;
procedure citire;
var i,j:byte;f:text; k:int64;
begin
assign(f,'flip.in');
reset(f);
readln(f,n,m);
for i:=1 to n do
begin
k:=0;
for j:=1 to m do begin read(f,c[i,j]); write(c[i,j],' ');end;
writeln;
readln(f);
end;
close(f);
end;
procedure aras;
var i,j,h:byte; s,k:int64;
begin
s:=0;
for i:=1 to n do
begin
k:=0;
for j:=1 to m do begin k:=k+c[i,j]*a[j]; end;
s:=s+abs(k);
end;
if s>max then max:=s;
end;
procedure gen_bin(p:byte);
begin
if p>m then aras
else begin
a[p]:=-1; gen_bin(p+1);
a[p]:=1; gen_bin(p+1);
end;
end;
begin
citire;
max:=0;
gen_bin(1);
assign(f,'flip.out');
rewrite(f);
writeln(f,max);
close(f);
end.