#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define endl "\n"
void move_inside (int i);
void move_outside (int i);
int press_button (void);
int min_cardinality (int N) {
int cur_max = 0;
vvi groups;
for (int i = 0; i < N; i++) {
move_inside(i);
int get = press_button();
if (get > cur_max) {
cur_max = get;
groups.pb({i});
}
else {
move_outside(i);
bool ok = false;
for (auto& gr : groups) {
move_inside(i);
int temp = press_button();
move_outside(i);
if (temp > cur_max) {
gr.pb(i);
ok = true;
break;
}
}
if (!ok) {
move_inside(i);
groups.pb({i});
cur_max = press_button();
}
else {
move_inside(i);
}
}
}
int ans = INT_MAX;
for (auto gr : groups) {
ans = min(ans, (int)gr.size());
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |