Cod sursa(job #2628032)
| Utilizator | Data | 14 iunie 2020 09:23:19 | |
|---|---|---|---|
| Problema | Jocul Flip | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<iostream>
#include<fstream>
using namespace std ;
int main()
{
ifstream f("flip.in");
ofstream g("flip.out");
int N,M,i,j,a[16][16],s_total=0,s=0;
f>>N>>M;
for(i=1;i<=N;i++)
for(j=1;j<=M;j++)
f>>a[i][j];
for(i=1;i<=N;i++)
{
s=0;
for(j=1;j<=M;j++)
{
s=s+a[i][j];
}
if(s<0)
{
s=0;
for(j=1;j<=M;j++)
{
if(a[i][j]<0)
a[i][j]=-a[i][j];
s=s+a[i][j];
}
}
s_total=s_total+s;}
g<<s_total;
return 0;
}
