This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
int HC(int N_)
{
int64_t N = N_, i = 1, j = N, k = 1 + (N * 95) / 100;
Guess(k);
while (i < j)
{
int64_t mid = (i + j) / 2;
if ((i - 1) * 20 < N)
mid = (75 * i + 25 * j) / 100;
else if ((N - j) * 20 < N)
mid = (25 * i + 75 * j) / 100;
int64_t q;
if (i == 1 && j == N)
q = min(1 + (N * 55) / 100, k - 1);
else
{
if (k < mid)
q = min(N, mid + (mid - k));
else if (k > mid)
q = max((int64_t)1, mid - (k - mid));
else
q = mid + 1 <= N ? mid + 1 : mid - 1;
}
int64_t x = Guess(q);
if (!x)
{
return min(k, q) + abs(k - q) / 2;
return 0;
}
if (x == 1)
{
if (q < k)
j = k - (k - q) / 2 - 1;
else
i = k + (q - k) / 2 + 1;
}
else
{
if (q < k)
i = q + (k - q) / 2 + 1;
else
j = q - (q - k) / 2 - 1;
}
k = q;
}
return i;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |