Pagini recente » Cod sursa (job #587887) | Concursul de Programare organizat de UTCN (ediția 2023) | Cod sursa (job #1917517) | Cod sursa (job #2949724) | Cod sursa (job #757615)
Cod sursa(job #757615)
var f,g:text;
m,n:integer;
a:array[1..16,1..16] of longint;
s,x,y:longint;
i,j:integer;
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]);
for i:=1 to n do begin
x:=0;y:=0;
for j:=1 to m do
if a[i,j]>0 then
x:=x+a[i,j]
else
y:=y+a[i,j];
if x<abs(y) then
for j:=1 to m do
a[i,j]:=-1*a[i,j];
end;
for i:=1 to m do begin
x:=0;
y:=0;
for j:=1 to n do
if a[j,i]>0 then
x:=x+a[j,i]
else
y:=y+a[j,i];
if x>abs(y) then
s:=s+x
else
s:=s+abs(y);
end;
write (g,s);
close(g);
end.