Pagini recente » Cod sursa (job #1760479) | Cod sursa (job #2344259) | Cod sursa (job #441264) | Cod sursa (job #1544182) | Cod sursa (job #2913480)
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("flip.in");
ofstream fout("flip.out");
int N, M;
fin >> N >> M;
long int a[N][M];
for (int i=0; i<N; i++)
for (int j=0; j<M; j++)
fin >> a[i][j];
int sum, s1, temp;
for (int bt=0; bt<(1<<M); bt++)
{
s1=0;
for (int i=0; i<N; i++)
{
temp=0;
for (int j=0; j<M; j++) if (bt&(1<<j)) temp+=-a[i][j]; else temp+=a[i][j];
if (temp<0) s1+=-temp; else s1+=temp;
}
if (s1>sum) sum=s1;
}
fout << sum;
}