55842023-08-02 12:25:24TomaSajtSakktábla (75 pont)cpp17Accepted 75/753ms4068 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 <= 1001; k++) {
    if (!possible(k)) {
      sol = k - 1;
      break;
    }
  }
  cout << sol;
  */

  /*
  int l = 0, r = 1001;
  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/03ms1916 KiB
2Accepted0/03ms2068 KiB
3Accepted5/53ms2320 KiB
4Accepted5/53ms2528 KiB
5Accepted5/53ms2772 KiB
6Accepted5/52ms2832 KiB
7Accepted5/52ms2968 KiB
8Accepted5/52ms3180 KiB
9Accepted5/53ms3372 KiB
10Accepted5/53ms3608 KiB
11Accepted7/73ms3724 KiB
12Accepted7/72ms3836 KiB
13Accepted7/73ms3976 KiB
14Accepted7/72ms4056 KiB
15Accepted7/72ms4068 KiB