Cod sursa(job #542911)

Utilizator informatician29kill03 informatician29 Data 27 februarie 2011 10:17:06
Problema Jocul Flip Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include<fstream>
using namespace std;
ifstream f("flip.in");
ofstream g("flip.out");
int n, m, a[17][17], x[17], k,i,j,smax=-1;
void prelsol(){
    int stot=0,s,i,j;
    for(i=1; i<=n; i++){
	s=0;
	for(j=1; j<=m; j++) if(x[j]) s-=a[i][j]; else s+=a[i][j];
	if(s<0) stot-=s;else stot+=s;
    }
    if(stot>smax) smax=stot;
}

int main(){
    f>>n>>m;
    for(i=1; i<=n; i++)
	for(j=1; j<=m; j++) f>>a[i][j];
    prelsol();
    g<<smax<<'\n';g.close(); return 0;
}