제출 #794364

#제출 시각아이디문제언어결과실행 시간메모리
794364IvanJ드문 곤충 (IOI22_insects)C++17
47.50 / 100
209 ms524 KiB
#include "insects.h" #include<bits/stdc++.h> #define pb push_back #define x first #define y second #define all(a) (a).begin(), (a).end() using namespace std; typedef long long ll; typedef pair<int, int> ii; int n, D; int check(int x) { vector<int> in; for(int i = 0;i < n;i++) { move_inside(i); if(press_button() > x) move_outside(i); else in.pb(i); } for(int i : in) move_outside(i); return ((int)in.size() == x * D); } int min_cardinality(int N) { n = N, D = 0; vector<int> v; for(int i = 0;i < n;i++) { move_inside(i); if(press_button() > 1) move_outside(i); else v.pb(i), D++; } for(int i : v) move_outside(i); int lo = 2, hi = n, ans = 1; while(lo <= hi) { int mid = (lo + hi) / 2; if(check(mid)) ans = mid, lo = mid + 1; else hi = mid - 1; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...