Submission #787617

#TimeUsernameProblemLanguageResultExecution timeMemory
787617AndreyRarest Insects (IOI22_insects)C++17
0 / 100
1 ms296 KiB
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;

int n;

bool check(int a) {
    vector<bool> bruh(n,true);
    int br = n;
    for(int i = 0; i < n; i++) {
        move_inside(i);
        if(press_button() > a) {
             bruh[a] = false;
             move_outside(i);
             br--;
        }
    }
    for(int i = 0; i < n; i++) {
        if(bruh[i]) {
            move_outside(i);
        }
    }
    if(br == n*a) {
        return false;
    }
    else {
        return true;
    }
}

int min_cardinality(int N) {
    n = N;
    int l = 1,r = n,m;
    while(l < r) {
        m = (l+r)/2;
        if(check(m)) {
            r = m;
        }
        else {
            l = m+1;
        }
    }
    return l;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...