Submission #823095

#TimeUsernameProblemLanguageResultExecution timeMemory
823095finn__Rarest Insects (IOI22_insects)C++17
56.41 / 100
116 ms420 KiB
#include <bits/stdc++.h> #include "insects.h" std::bitset<2000> in_machine, deleted; int min_cardinality(int N) { int d = 0; for (int i = 0; i < N; ++i) { move_inside(i); if (press_button() > 1) move_outside(i); else ++d, in_machine[i] = 1; } int a = 1, b = N; while (a < b) { int const mid = (a + b + 1) >> 1; std::vector<int> moved; int inside = in_machine.count(); for (int i = 0; i < N && inside < d * mid; ++i) if (!deleted[i] && !in_machine[i]) { move_inside(i); if (press_button() > mid) move_outside(i); else in_machine[i] = 1, moved.push_back(i), ++inside; } if (inside == d * mid) { a = mid; } else { b = mid - 1; deleted |= ~in_machine; for (auto const &i : moved) in_machine[i] = 0, move_outside(i); } } return a; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...