Pagini recente » Monitorul de evaluare | Cod sursa (job #1001212) | Cod sursa (job #1742670) | Cod sursa (job #582021) | Cod sursa (job #3308877)
#include <bits/stdc++.h>
using namespace std;
long long mat[20][20], v[20];
int main()
{
freopen("flip.in", "r",stdin);
freopen("flip.out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, m,maxx=0;
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>mat[i][j];
while(v[0]!=1)
{
for(int i=1;i<=n;i++)
if(v[i]==1)
for(int j=1;j<=m;j++)
mat[i][j]=-mat[i][j];
long long st=0, s;
for(int j=1;j<=m;j++)
{
s=0;
for(int i=1;i<=n;i++)
s+=mat[i][j];
if(s<0)
st+=-s;
else st+=s;
}
if(st>maxx)
maxx=st;
int i=n;
while(v[i]==1)
{
v[i]=0;
i--;
}
v[i]=1;
}
cout<<maxx;
return 0;
}