Pagini recente » Cod sursa (job #2650364) | Cod sursa (job #3201160) | Cod sursa (job #2669970) | Cod sursa (job #2665538) | Cod sursa (job #3211389)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("flip.in");
ofstream fout("flip.out");
int n, m, a[20], b[20][20];
int main()
{
int i, j, total, s, smax = INT_MIN;
fin >> n >> m;
for(i = 1;i <= n;i++)
for(j = 1;j <= m;j++)
fin >> b[i][j];
while(a[0] == 0)
{
total = 0;
for(i = 1;i <= n;i++)
{
s = 0;
for(j = 1;j <= m;j++)
if(a[j] == 0) s += b[i][j];
else s -= b[i][j];
total += abs(s);
}
smax = max(smax, total);
for(j = m;a[j] == 1;j--)
a[j] = 0;
a[j] = 1;
}
fout << smax << "\n";
fout.close();
return 0;
}