Pagini recente » Cod sursa (job #3032420) | Cod sursa (job #1691562) | Cod sursa (job #1671827) | Cod sursa (job #1420704) | Cod sursa (job #8822)
Cod sursa(job #8822)
#include<fstream.h>
long n,m,a[16][16],smax;
int main()
{
long i,j,k,s,t;
ifstream f("flip.in");
ofstream g("flip.out");
f>>n>>m;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
f>>a[i][j];
for(i=0;i<(1<<m);i++)
{
s=0;
for(k=0;k<n;k++)
{
for(t=j=0;j<m;j++)
if(i&(1<<j))
t+=-a[k][j];
else
t+=a[k][j];
s+=t<-t ?-t : t;
}
if(smax<s)
smax=s;
}
g<<smax;
return 0;
}