Pagini recente » Cod sursa (job #496074) | Cod sursa (job #468898) | Cod sursa (job #1521756) | Cod sursa (job #1750578) | Cod sursa (job #3211397)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("test.in");
ofstream fout("test.out");
int a[20], b[20][20], n, m;
int main()
{
int i, j, s, smax, stot;
fin >> n >> m;
for(i = 1; i <= n; i++)
fin >> b[i][j];
smax = stot = -1;
while(a[0] == 0)
{
for(j = 1; j <= n; j++)
{
s = 0;
for(i = 1; i <= m; i++)
if(a[i] == 0) s += b[i][j];
else s -= b[i][j];
smax += abs(s);
}
stot = max(smax, stot);
for(i = m; a[i] == 1; i--)
a[i] = 0;
a[i] = 1;
}
fout << stot;
return 0;
}