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 <vector>
using namespace std;
int n;
int count_insects(int bound) {
vector<int> insects;
for (int i = 0; i < n; i++) {
move_inside(i);
if (press_button() > bound) move_outside(i);
else insects.push_back(i);
}
for (auto i : insects) move_outside(i);
return (int)insects.size();
}
int min_cardinality(int N) {
n = N;
int groups = count_insects(1);
int l = 2, r = n, ans = 1;
while (l <= r) {
int mid = (l + r) / 2;
if (count_insects(mid) == groups * mid) {
ans = mid;
l = mid + 1;
}
else r = mid - 1;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |