# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
726334 | ismayil | Rarest Insects (IOI22_insects) | C++17 | 218 ms | 532 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
//g++ -std=c++17 insects.cpp stub.cpp
int D, N;
bool check(int m){
vector<int> in;
for(int j = 0; j < N; j++){
move_inside(j);
if(press_button() > m){
move_outside(j);
}else{
in.push_back(j);
}
}
bool flag = false;
if(in.size() < m * D){
flag = true;
}
while(!in.empty()) move_outside(in.back()), in.pop_back();
return flag;
}
int min_cardinality(int n) {
N = n;
vector<int> in;
for(int j = 0; j < N; j++){
move_inside(j);
if(press_button() > 1){
move_outside(j);
}else{
in.push_back(j);
}
}
D = in.size();
while(!in.empty()) move_outside(in.back()), in.pop_back();
int l = 1, r = N / D;
while(l <= r){
int m = (l + r) / 2;
if(check(m)) r = m - 1;
else l = m + 1;
}
return r;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |