#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_val = 1001; cin >> N >> M; int maze[N][M]; 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]; } } } if(M % 2 == 1 || N % 2 == 1) { cout << sum; return 0; } sum -= min_val; cout << sum; return 0; }