Cod sursa(job #20535)
Utilizator | Bugnaru Gelu gangstacorny | Data | 21 februarie 2007 18:38:26 |
---|---|---|---|
Problema | Jocul Flip | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include<stdio.h>
long n,m,a[1001][1001],smax;
long i,j,k,s,t;
int main()
{
freopen("flip.in","r",stdin);
freopen("flip.out","w",stdout);
scanf("%lld %lld",&n ,&m);
for(i=0;i<n;i++)
for(j=0;j<m;j++)
scanf("%lld", 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;
}
printf("%lld",smax);
return 0;
}