55862023-08-02 12:30:11TomaSajtSakktábla (75 pont)cpp17Accepted 75/753ms3696 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  if (n > m) swap(n, m);

  auto possible = [&](int k) {
    int k2 = k * k;
    return n >= k2 / 2 && m >= (k2 + 1) / 2;
  };

  

  int sol = -1;
  for (int k = 1; k <= 1500; k++) {
    if (!possible(k)) {
      sol = k - 1;
      break;
    }
  }
  cout << sol;

  

  /*

  int l = 0, r = 1500;
  while (l < r - 1) {
    int m = (l + r) / 2;
    if (possible(m)) {
      l = m;
    }
    else {
      r = m;
    }
  }
  cout << l;

  */

  /*

  int sqrt_2n = sqrt(2 * n);
  int sqrt_2np1 = sqrt(2 * n + 1);
  if (m != n && sqrt_2n % 2 == 0 && sqrt_2np1 % 2 == 1) {
    cout << sqrt_2n + 1;
  }
  else {
    cout << sqrt_2n;
  }

  */
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1872 KiB
2Accepted0/03ms2116 KiB
3Accepted5/53ms2396 KiB
4Accepted5/53ms2492 KiB
5Accepted5/52ms2544 KiB
6Accepted5/52ms2544 KiB
7Accepted5/53ms2684 KiB
8Accepted5/53ms2900 KiB
9Accepted5/53ms3104 KiB
10Accepted5/52ms3348 KiB
11Accepted7/72ms3212 KiB
12Accepted7/72ms3200 KiB
13Accepted7/73ms3448 KiB
14Accepted7/73ms3696 KiB
15Accepted7/72ms3624 KiB