Cod sursa(job #3279087)
| Utilizator | Data | 21 februarie 2025 20:43:07 | |
|---|---|---|---|
| Problema | Jocul Flip | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | lasm_21_02_2025_clasa11 | Marime | 0.61 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream in("flip.in");
ofstream out("flip.out");
int N,M;
long long a[16][16];
int main()
{
in>>N>>M;
for(int i=0;i<N;i++)
for(int j=0;j<M;j++)
in>>a[i][j];
long long ans=LLONG_MIN;
for(int mask=0;mask<(1<<N);mask++)
{
long long total=0;
for(int j=0;j<M;j++)
{
long long colSum=0;
for(int i=0;i<N;i++)
colSum+=(mask&(1<<i))?-a[i][j]:a[i][j];
total+=max(colSum,-colSum);
}
ans=max(ans,total);
}
out<<ans<<"\n";
}
