Cod sursa(job #2466175)

Utilizator Andrei800Radulescu Andrei Andrei800 Data 1 octombrie 2019 17:50:12
Problema Jocul Flip Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    int n,m,s(0),x,y;
    ifstream in("flip.in");
    ofstream out("flip.out");
    in >> n;
    in >> m;
    int a[n][m];
    for(x=1;x<=n;x++)
    {
        for(y=1;y<=m;y++)
        {
            in>>a[x][y];
        }
        if((a[x][y-2]+a[x][y-1]+a[x][y])>=(-a[x][y-2]-a[x][y-1]-a[x][y]))
        {
            s=s+a[x][y-2]+a[x][y-1]+a[x][y];
        }
        else
        {
            s=s-a[x][y-2]+a[x][y-1]+a[x][y];
        }
    }
    out << s;
    return 0;
}