Cod sursa(job #3338432)

Utilizator postolacheepostolache postolachee Data 3 februarie 2026 11:01:59
Problema Jocul Flip Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.14 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize ("O3")
#define pb push_back
using namespace std;


signed main(){
    ifstream cin ("flip.in");
    ofstream cout ("flip.out");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;cin >> n >> m;
    vector <vector <int>> a(n + 2, vector <int>(m + 2, 0));
    vector <int> deltax(n + 2),  deltay(m + 2);
    
    for(int i=1;i <= n;i++){
        int ss=0;
        for(int j=1;j <= m;j++){
            cin >> a[i][j];
            ss+=a[i][j];
        }
        if(ss <= 0){
            for(int j=1;j <= m;j++)a[i][j] *= -1;
        }
    }
    int ff=0;
    for(int j=1;j <= m;j++){
        int ss=0;
        for(int i=1;i <= n;i++){
            ss+=a[i][j];
        }
        ff += abs(ss);
    }
    cout << ff;
    return 0;
}