l = 1, r = m; int ans; while (l <= r) { mid = (l + r) >> 1; if (check(mid)) { ans= mid; r = mid - 1; } else { l = mid + 1; } } printf("%d\n", ans);