제출 #634211

#제출 시각아이디문제언어결과실행 시간메모리
634211flappybird드문 곤충 (IOI22_insects)C++17
99.95 / 100
87 ms416 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; #define MAX 2020 int chk[MAX]; int num[MAX]; int min_cardinality(int N) { int K; K = 0; int i; int on = 0; for (i = 0; i < N; i++) { move_inside(i); if (press_button() > 1) move_outside(i); else num[i] = 1, chk[i] = 1, on++; } int l, r; K = on; l = 1, r = N / K + 1; while (r - l > 1) { int mid = (l + r) / 2; vector<int> nb; for (i = 0; i < N; i++) { if (!chk[i] && !num[i]) { move_inside(i); if (press_button() > mid) { nb.push_back(i); move_outside(i); } else { chk[i] = 1; on++; } } if (on == mid * K) break; } if (on == mid * K) { for (i = 0; i < N; i++) if (chk[i]) num[i] = 1; l = mid; } else { for (auto v : nb) num[v] = -1; for (i = 0; i < N; i++) if (chk[i] && !num[i]) chk[i] = 0, move_outside(i), on--; r = mid; } } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...