Mai intai trebuie sa te autentifici.
Cod sursa(job #1073114)
Utilizator | Data | 5 ianuarie 2014 17:45:35 | |
---|---|---|---|
Problema | Jocul Flip | Scor | 80 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.74 kb |
program flip;
var t:array[1..20,1..20]of longint;
n,i,j,m,max:longint;
procedure schimbalinie(i:integer);
var j:integer;
begin
for j:=1 to n do
t[i,j]:=t[i,j]*(-1);
end;
procedure suma();
var i,j:longint; suma,p:int64;
begin suma:=0;
for i:=1 to m do
begin
p:=0;
for j:=1 to n do
p:=p+t[j,i];
if p<0 then p:=(-1)*p;
suma:=suma+p;
end;
if max<suma then max:=suma;
end;
procedure back(x:integer);
begin
if x=n+1 then suma else
begin
schimbalinie(x);
back(x+1);
schimbalinie(x);
back(x+1);
end;
end;
begin
assign(input,'flip.in');reset(input);
assign(output,'flip.out');rewrite(output);
readln(n,m);
for i:=1 to n do
for j:=1 to m do
read(t[i,j]);
max:=-1000000000;
back(1);
writeln(max);
close(input);close(output);
end.