Pagini recente » Cod sursa (job #446191) | Cod sursa (job #2830827) | Cod sursa (job #1030521) | Cod sursa (job #3273635) | Cod sursa (job #370024)
Cod sursa(job #370024)
program joculflip;
uses crt;
var f,g:text;
a:array[1..16,1..16]of longint;
n,m,l,k,i,j,o:byte;
s,s2,smax:longint;
begin
assign(f,'flip.in');
reset(f);
assign(g,'flip.out');
rewrite(g);
readln(f,n,m);
for i:=1 to n do
begin
for j:=1 to m do
read(f,a[i,j]);
readln(f);
end;
s:=0;
smax:=0;
o:=0;
repeat
o:=o+1;
for i:=1 to n do
a[o,i]:=a[o,i]*(-1);
for i:=1 to m do
begin
for j:=1 to n do
a[j,i]:=a[j,i]*(-1);
for k:=1 to n do
for l:=1 to m do
s:=s+a[k,l];
if s>smax then
smax:=s;
s:=0;
for j:=1 to n do
a[j,i]:=a[j,i]*(-1);
end;
for i:=1 to n do
a[o,i]:=a[o,i]*(-1);
until o=n;;
writeln(g,smax);
close(f);
close(g);
end.