# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
825868 | LittleCube | Rarest Insects (IOI22_insects) | C++17 | 289 ms | 512 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.
#include "insects.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const double r = 0.4;
int min_cardinality(int N)
{
vector<int> remain;
int M = N, L = 1, R = N;
/*
Choose k:
ans <= k -> R = k
ans > k -> L = k + 1, M -= k
*/
for (int i = 0; i < N; i++)
remain.emplace_back(i);
while (L < R)
{
int k = L * (1.0 - r) + R * r;
vector<int> small, large, tmp, out;
for (int i : remain)
{
move_inside(i);
if (press_button() > k)
{
move_outside(i);
large.emplace_back(i);
}
else
small.emplace_back(i);
}
for (auto i : small)
move_outside(i);
if (large.empty())
R = k;
else
{
for (auto i : large)
{
move_inside(i);
if (press_button() == 2)
move_outside(i);
else
out.emplace_back(i);
}
int g = out.size();
for (auto i : small)
{
move_inside(i);
if (press_button() == 2)
large.emplace_back(i);
else
tmp.emplace_back(i);
move_outside(i);
}
for (auto i : out)
move_outside(i);
if (tmp.empty())
{
if (g == 1)
return large.size();
L = k + 1, R = min(R, (int)remain.size() / g);
}
else
remain = tmp, R = k;
}
}
return L;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |