Cod sursa(job #19281)
| Utilizator | Data | 19 februarie 2007 09:21:58 | |
|---|---|---|---|
| Problema | Jocul Flip | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.42 kb |
#include <stdio.h>
long n,m,a[16][16],smax;
int main(){
long i,j,k,s,t;
FILE *f,*g;
f=fopen("flip.in","r");
g=fopen("flip.out","w");
fscanf(f,"%lld %lld",&n,&m);
for(i=0;i<n;i++)
for(j=0;j<m;j++) fscanf(f,"%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;
}
fprintf(g,"%lld\n",smax);
return 0;
}