# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
630005 | il9 | Rarest Insects (IOI22_insects) | C++17 | 0 ms | 0 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.
#include <bits/stc++.h>
#include "insects
using namespace std;
int min_cardinality(int n)
{
for(int i =0;i<n;i++)
{
move_inside(i);
}
for(int i=0;i<n;i++) move_outside(i);
int low=1;
int high=press_button();
int mid;
bool inside[n];
for(int i=0;i<n;i++)
{
inside[i]=0;
}
while(low<high)
{
mid=(low+high)/2;
int addded=0;
for(int i=0;i<n;i++)
{
if(!inside[i])
{
move_inside(i);
inside[i]=1;
int tp=press_button();
added++;
if(tp>mid)
{
inside[i]=0;
added--;
move_outside(i);
}
}
}
if(n-added%mid==0)
{
low=mid+1;
}else
{
high=mid;
for(int i=0;i<n;i++)
{
inside[i]=0;
}
}
}
return high;
}