#include #include #include "queue" #include int main() { int rows = 0; int cols = 0; std::cin >> rows; std::cin >> cols; std::map, int> map; int tmp; int sum = 0; for (int x = 0; x> tmp; sum += tmp; map.insert({{x, y}, tmp}); } } if (rows%2 == 1 || cols%2==1) { std::cout << sum << std::endl; } else { int max = 0; int tmp = 0; for ( int i= 0; i< rows;i++){ for (int j = 0; j < cols;j++) { if((j == 0 && i%2==0) ||( j == (cols-1) && i%2==1)){ continue; }else{ tmp += map.at({i,j}); } } if (sum - tmp > max){ max = sum - tmp; } tmp = 0; } for ( int j = 0; j < cols;j++){ for (int i= 0; i< rows;i++) { if((i == 0 && j%2==0) || (i == (rows-1) && j%2==1)){ continue; }else{ tmp += map.at({i,j}); } } if (sum - tmp > max){ max = sum - tmp; } tmp = 0; } std::cout << max << std::endl; } return 0; }