제출 #758845

#제출 시각아이디문제언어결과실행 시간메모리
758845amunduzbaev드문 곤충 (IOI22_insects)C++17
56.41 / 100
129 ms416 KiB
#include "insects.h" #ifndef EVAL #include "stub.cpp" #endif #include "bits/stdc++.h" using namespace std; int min_cardinality(int n) { vector<int> used, rem; for(int i=0;i<n;i++){ move_inside(i); if(press_button() > 1){ move_outside(i); rem.push_back(i); } else { used.push_back(i); } } int cnt = used.size(); for(auto x : used){ move_outside(x); } swap(used, rem); auto check = [&](int mid){ vector<int> in, rem; for(auto x : used){ move_inside(x); if(press_button() > mid){ move_outside(x); rem.push_back(x); } else { in.push_back(x); } } if((int)in.size() < mid * cnt){ swap(used, in); for(auto x : used) move_outside(x); return false; } else { swap(used, rem); for(auto x : in) move_outside(x); return true; } }; int l = 0, r = n - 1; int res = 1; while(l < r){ int mid = (l + r + 1) >> 1; if(check(mid)){ res += mid; l = 0, r -= mid; } else { r = mid - 1; } } //~ cout<<res<<"\n"; return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...