#include using namespace std; /* compile hamster.cpp && ./hamster < hamsterfiles/1.in*/ /* compile hamster.cpp && ./hamster < hamsterfiles/2.in*/ int main () { int N, M; /* size of hamster maze */ int sum = 0; int min_i = 0, min_j = 0; int min_val = 1001; cin >> N >> M; int maze[M][N]; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cin>>maze[i][j]; sum += maze[i][j]; /*!(i == 0 && j == 0) && !(i == N-1 && j == M-1)*/ if(maze[i][j] < min_val && (i+j)%2 ==1) { min_val = maze[i][j]; min_i = i; min_j = j; } } } if(M % 2 == 1 || N % 2 == 1) { cout << sum; return 0; } sum -= min_val; cout << sum; return 0; cout << sum; return 0; }