Pagini recente » Cod sursa (job #2625528) | Cod sursa (job #533464) | Cod sursa (job #2476513) | Istoria paginii runda/jc2021-runda2/clasament | Cod sursa (job #915431)
Cod sursa(job #915431)
var a:array[0..200,0..200] of longint;
bit:array[0..20000] of integer;
fi, fo:text;
i, j, m, n:integer;
aux, poz, s, s1, k, smax:longint;
begin
assign(fi, 'flip.in');
reset(fi);
assign(fo, 'flip.out');
rewrite(fo);
read(fi, n,m);
for j:=1 to n do
for i:=1 to m do
read(fi, a[i,j]);
for i:=1 to (1 shl n)-1 do begin
aux:=i; poz:=0;
while aux>0 do begin
if aux mod 2=0 then bit[poz]:=1
else bit[poz]:=0;
aux:=aux shr 1;
poz:=poz+1;
end;
end;
s:=0;
for k:=1 to m do begin
s1:=0;
for j:=1 to n do
if bit[j]=1 then s1:=s1+a[k,j]
else s1:=s1-a[k,j];
if (s1<0) then s:=s-s1
else s:=s+s1;
end;
if s>smax then smax:=s;
writeln(fo,s);
close(fi);
close(fo);
end.