Mai intai trebuie sa te autentifici.
Cod sursa(job #2366902)
| Utilizator | Data | 4 martie 2019 22:46:56 | |
|---|---|---|---|
| Problema | Jocul Flip | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.72 kb |
#include <fstream>
using namespace std;
ifstream fin("flip.in");
ofstream fout("flip.out");
long long i,j,N,M;
long a[20][20], maxim=0, s[20];
void cont(){
long long sl, st=0, i, j;
for(i=1;i<=M;i++){
sl=0;
for(j=1;j<=N;j++)
sl+=s[j]*a[j][i];
if(sl<0)
sl=-sl;
st+=sl;
}
if(st>maxim)
maxim=st;
}
void back(int k){
if(k>N)
cont();
else{
s[k]=1;
back(k+1);
s[k]=-1;
back(k+1);
}
}
int main()
{
fin>>N>>M;
for(i=1;i<=N;i++)
for(j=1;j<=M;j++)
fin>>a[i][j];
back(1);
fout<<maxim;
fin.close();
fout.close();
return 0;
}
