| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 725670 | aykhn | Rarest Insects (IOI22_insects) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
int min_cardinality(int n)
{
int sz = 0;
vector<int> out;
for (int i = 0; i < n; i++)
{
move_inside(i);
int x = press_button();
if (x > 1)
{
move_outside(i);
out.pb(i);
}
else sz++;
}
int best = 1;
int rn = sz;
int l = 2;
int r = n/sz;
while (l <= r)
{
int mid = (l + r) >> 1;
vector<int> temp;
vector<int> nout;
for (int i = 0; i < out.size(); i++)
{
move_inside(out[i]);
int x = press_button();
if (x > mid)
{
nout.pb(out[i]);
move_outside(out[i]);
}
else
{
rn++;
temp.pb(out[i]);
}
if (rn == mid * sz)
{ // fill out to next out (nout)
for (int j = i + 1; j < out.size(); j++) nout.pb(out[j]);
break;
}
}
// if true, previous elements not needed
// current elements not needed ?? yes
if (rn == mid * sz)
{
best = max(best, mid);
l = mid + 1;
out = nout;
}
else
{
r = mid - 1;
for (int x : temp) move_outside(x);
}
}
return best;
}
