Pagini recente » Cod sursa (job #1417214) | Borderou de evaluare (job #2002078) | Cod sursa (job #2277788) | Cod sursa (job #1662522) | Cod sursa (job #195086)
Cod sursa(job #195086)
var f,g:text;
l1,c:array[1..16] of longint;
a:array[1..32] of longint;
n,m,l,i,x,xx,j,s,max,q:longint;
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 begin
read(f,q);
inc(l);
l1[i]:=l1[i]+q;
c[j]:=c[j]+q;
end;
l:=0;
for i:=1 to n do begin
inc(l);
a[l]:=l1[i];
end;
for i:=1 to m do begin
inc(l);
a[l]:=c[i];
end;
max:=0;
for i:=1 to l do max:=max+a[i];
max:=max div 2;
for x:=1 to 1 shl l-1 do begin
xx:=x;
s:=max;
for i:=1 to l do begin
if xx mod 2=1 then begin
dec(s,a[i]);
inc(s,a[i]*-1);
end;
xx:=xx div 2;
end;
if s>max then max:=s;
end;
writeln(g,max);
close(f);
close(g);
end.