Submission #631044

#TimeUsernameProblemLanguageResultExecution timeMemory
631044gromperenRarest Insects (IOI22_insects)C++17
99.89 / 100
64 ms460 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(int N) { vector<int> insects; int cnt_uniq = 0; for (int i = 0; i < N; ++i) { move_inside(i); if (press_button() == 1) cnt_uniq++; else { move_outside(i); insects.push_back(i); } } int ans = 1; int low = 2, high = N/cnt_uniq; while(low<=high) { int mid = (low+high)/2; vector<int> in, out; for (int i : insects) { move_inside(i); if (press_button() > mid) { move_outside(i); out.push_back(i); } else { in.push_back(i); } } if (in.size() == cnt_uniq * (mid-ans)) { low = mid+1; ans = mid; insects = out; } else { high = mid-1; insects = in; for (auto i : in) move_outside(i); } } return ans; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:33:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |   if (in.size() == cnt_uniq * (mid-ans)) {
      |       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...