Cod sursa(job #2386770)

Utilizator oogaboogauvuvwevwevwe onyetenyevwe ugwemubwem ossas oogabooga Data 23 martie 2019 17:13:52
Problema Jocul Flip Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <bits/stdc++.h>

using namespace std;

ifstream in("flip.in");
ofstream out("flip.out");

int64_t n, m, a[17][17], MAX;

int main()
{
    in >> n >> m;
    for(int64_t i = 1; i <= n; ++i)
        for(int64_t j = 1; j <= m; ++j)
            in >> a[i][j];

    for(int64_t i = 1; i <= n; ++i)
        for(int64_t j = 1; j <= m; ++j)
        {
            int64_t S = 0;
            for(int64_t x = 1; x <= n; ++x)
                for(int64_t y = 1; y <= n; ++y)
                    if((x == i && y == j) || (x != i && y != j))
                        S += a[x][y];
                    else
                        S -= a[x][y];
            MAX = max(MAX, S);
        }

    out << MAX;


    return 0;
}