Submission #627762

#TimeUsernameProblemLanguageResultExecution timeMemory
627762FischerRarest Insects (IOI22_insects)C++17
0 / 100
28 ms208 KiB
#include <bits/stdc++.h> #include "insects.h" using namespace std; const int maxn = 2010; bool in[maxn]; pair<bool, int> p(int x, int N) { for (int i = 0; i < N; ++i) { move_inside(i); in[i] = 1; if (press_button() > x) { move_outside(i); in[i] = 0; } } for (int i = 0; i < N; ++i) { if (in[i]) { move_outside(i); } } int cnt = 0, bad = 0; for (int i = 0; i < N; ++i) { if (in[i]) { move_inside(i); in[i] = 0; if (press_button() >= x) { move_outside(i); in[i] = 1; bad += 1; } cnt += 1; } } return {cnt == bad * x, bad}; } int min_cardinality(int N) { pair<bool, int> temp; int lo = 1, hi = min(N, 1000); while (lo < hi) { int mid = (lo + hi + 1) / 2; if ((temp = p(mid, N)).first) lo = mid; else hi = mid-1; } return lo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...