Cod sursa(job #3211397)
| Utilizator | Data | 9 martie 2024 11:20:55 | |
|---|---|---|---|
| Problema | Jocul Flip | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.67 kb |
#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;
}
