Submission #1232332

#TimeUsernameProblemLanguageResultExecution timeMemory
1232332badge881Rarest Insects (IOI22_insects)C++20
0 / 100
0 ms408 KiB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

int n;

int posOfKFirstOf(int K)
{
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        move_inside(i);
        if (press_button() > K)
        {
            move_outside(i);
            continue;
        }
        res++;
    }
    return res;
}

int min_cardinality(int N)
{
    n = N;
    int nbTypes = posOfKFirstOf(1);
    int left = 0, right = n / nbTypes;
    while (left < right - 1)
    {
        int mid = (left + right) / 2;
        if (posOfKFirstOf(mid) < nbTypes * mid)
            right = mid;
        else
            left = mid;
    }
    return left;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...