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;
const int maxn = 2e3 + 5;
int n;
vector<int> insects;
bool ban[maxn];
int count_insects(int bound) {
insects.clear();
for (int i = 0; i < n; i++) {
if (ban[i]) continue;
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);
if (groups == n) return 1;
for (auto i : insects) ban[i] = 1;
int l = 2, r = n / groups, ans = 1;
while (l <= r) {
int mid = (l + r) / 2;
if (count_insects(mid) == groups * (mid - ans)) {
ans = mid;
for (auto i : insects) ban[i] = 1;
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... |