제출 #726765

#제출 시각아이디문제언어결과실행 시간메모리
726765murad_2005드문 곤충 (IOI22_insects)C++17
0 / 100
196 ms352 KiB
#include "insects.h" #include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define pii pair<int, int> #define piii pair<int, pii> #define pb push_back #define all(v) v.begin(), v.end() #define size(v) v.size() #define f first #define s second #define INF 1e9 using namespace std; bool check(int x, int Types, int N, set<int>&pos){ for(int i = 0; i < N; ++i){ move_inside(i); if(press_button() > x){ move_outside(i); }else{ pos.insert(i); } } int Size = size(pos); if(Size == x * Types){ return true; } return false; } int min_cardinality(int N) { set<int>pos; for(int i = 0; i < N; ++i){ move_inside(i); if(press_button() > 1){ move_outside(i); }else{ pos.insert(i); } } int Types = size(pos); int low = 2, high = N / Types, best = 1; while(low <= high){ // is it possible to encounter at least mid element for every type? int mid = (low + high) >> 1; if(check(mid, Types, N, pos)){ low = mid + 1; best = mid; }else{ high = mid - 1; } } return best; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...