제출 #629254

#제출 시각아이디문제언어결과실행 시간메모리
629254jakubd드문 곤충 (IOI22_insects)C++17
47.50 / 100
240 ms420 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(int N) { int D = 1; vector<int> inside(N), outside(N); move_inside(0); inside[0] = 1; for (int i = 1; i < N; i++) { move_inside(i); if (press_button() == 2) { move_outside(i); outside[i] = 1; } else { D++; inside[i] = 1; } } for (int i = 0; i < N; i++) { if (inside[i]) { move_outside(i); } } int l = 1, r = N / D, ans = N; while (l <= r) { int m = (l + r) / 2; int cur = 0; inside.assign(N, 0), outside.assign(N, 0); for (int i = 0; i < N; i++) { move_inside(i); if (press_button() > m) { outside[i] = 1; move_outside(i); } else { inside[i] = 1; cur++; } } for (int i = 0; i < N; i++) { if (inside[i]) { move_outside(i); } } if (cur >= D * m) { l = m + 1; ans = m; } else { if (l == r) break; r = m; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...