Pagini recente » Cod sursa (job #1827423) | Cod sursa (job #3238131) | Cod sursa (job #2307694) | Cod sursa (job #1575423) | Cod sursa (job #308200)
Cod sursa(job #308200)
const d:array[1..2] of integer=(1,-1);
var f,g:text;
sol:array[0..17] of longint;
a:array[0..17,0..17] of longint;
n,m,i,j,suma:longint;
procedure calcul;
var i,j,s:longint;
begin
s:=0;
for j:=1 to m do begin
s:=a[1,j];
for i:=2 to n do
s:=s+sol[i]*a[i,j];
end;
if suma<s then suma:=s;
end;
procedure back(k:longint);
var i:longint;
begin
if k>n then begin
calcul;
end
else
for i:=1 to 2 do begin
sol[k]:=d[i];
back(k+1);
end;
end;
begin
assign(f,'flip.in');reset(f);
assign(g,'flip.out');rewrite(g);
read(f,n,m);
for i:=1 to n do
for j:=1 to m do
read(f,a[i,j]);
suma:=0;
back(1);
writeln(g,suma);
close(f);
close(g);
end.