fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5. typedef pair<int, int> pii;
  6.  
  7. #define INF (INT_MAX / 2)
  8. #define endl '\n'
  9.  
  10. #define MAX_N 1001
  11.  
  12. int n, m;
  13.  
  14. int main() {
  15. ios_base::sync_with_stdio(false); cin.tie(NULL);
  16.  
  17. cin >> n >> m;
  18. if (n > m)
  19. swap(n, m);
  20.  
  21. if (n == 1)
  22. cout << n << endl;
  23. else if (n == 2)
  24. cout << m / 4 * 4 + min(m % 4, 2) * 2 << endl;
  25. else
  26. cout << (n * m + 1) / 2 << endl;
  27.  
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 4544KB
stdin
Standard input is empty
stdout
0