Cod sursa(job #2357087)
| Utilizator | Data | 27 februarie 2019 09:32:44 | |
|---|---|---|---|
| Problema | Jocul Flip | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream fin("flip.in");
ofstream fout("flip.out");
int main()
{
int N,M;
int long long a[17][17],smax=0,sl=0,sc=0;
fin>>N>>M;
for(int i=0;i<N;i++)
{
sl=0;
for(int j=0;j<M;j++) {
fin>>a[i][j];
sl=sl+a[i][j];
if(j==M-1 && sl<0)
smax=smax+sl*-1;
else
smax=smax+sl;
}
}
for(int j=0;j<M;j++)
{
sc=0;
for(int i=0;i<N;i++)
{
sc=sc+a[i][j];
if(i==N-1 && sc<0)
smax=smax+sc*-1;
else
smax=smax+sc;
}
}
fout<<smax;
}
