Pagini recente » Cod sursa (job #1765540) | Istoria paginii utilizator/sebyi | Diferente pentru propuneri/9-okr intre reviziile 10 si 16 | Statistici porcescu gicu (gicu_01) | Cod sursa (job #608743)
Cod sursa(job #608743)
Program flip;
var m,n,i,j,max: longint;
a: array[1..16,1..16] of longint;
t: array[1..16] of shortint;
f: text;
Procedure citire;
var f: text;
Begin
assign(f, 'flip.in');
reset(f);
readln(f,n,m);
for i:=1 to n do
for j:=1 to m do
read(a[i,j]);
close(f);
end;
Procedure back(k: integer);
var s,s1: longint;
Begin
if k=n+1 then
Begin
s:=0;
for j:=1 to m do Begin
s1:=0;
for i:=1 to n do
s1:=s1+a[i,j]*t[i];
s:=s+ abs(s1);
end;
if s>max then max:=s;
end
else
Begin
t[k]:=1; back(k+1);
t[k]:=-1; back(k+1);
end;
end;
Begin
citire;
back(1);
assign(f, 'flip.out');
rewrite(f);
writeln(f,max);
close(f);
end.