#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(), x.end()
#define DBGY(x) cerr << #x << ": " << x << ", ";
#define DBG(x) cerr << #x << ": " << x << endl;
void move_inside(int i);
void move_outside(int i);
int press_button();
stack <int> in;
set <int> s;
int T;
bool check(int m, int &K) {
int old_k = K;
for (int i:s) {
move_inside(i);
if (press_button() <= m) {
in.push(i);
if (++K == m*T) {
while (!in.empty()) {
s.erase(in.top());
in.pop();
}
return true;
}
} else {
move_outside(i);
}
}
s.clear();
while (!in.empty()) {
s.insert(in.top());
move_outside(in.top());
in.pop();
}
K = old_k;
return false;
}
int min_cardinality(int N) {
move_inside(0);
in.push(0);
s.insert(0);
T = 1;
for (int i=1; i<N; i++) {
s.insert(i);
move_inside(i);
if (press_button() == 1) {
in.push(i);
T++;
} else {
move_outside(i);
}
}
while (!in.empty()) {
move_outside(in.top());
in.pop();
}
int K = 0, l = 0, r = N/T+1;
while (l+1 < r) {
assert(in.empty());
int m = (l+r)/2;
if (check(m, K)) {
l = m;
} else {
r = m;
}
}
return l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
4 ms |
208 KB |
Output is correct |
8 |
Correct |
3 ms |
208 KB |
Output is correct |
9 |
Correct |
6 ms |
296 KB |
Output is correct |
10 |
Correct |
3 ms |
208 KB |
Output is correct |
11 |
Correct |
4 ms |
208 KB |
Output is correct |
12 |
Correct |
5 ms |
208 KB |
Output is correct |
13 |
Correct |
6 ms |
208 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
5 ms |
208 KB |
Output is correct |
16 |
Correct |
3 ms |
208 KB |
Output is correct |
17 |
Correct |
5 ms |
208 KB |
Output is correct |
18 |
Correct |
4 ms |
304 KB |
Output is correct |
19 |
Correct |
5 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
5 ms |
208 KB |
Output is correct |
22 |
Correct |
3 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
4 ms |
208 KB |
Output is correct |
8 |
Correct |
3 ms |
208 KB |
Output is correct |
9 |
Correct |
6 ms |
296 KB |
Output is correct |
10 |
Correct |
3 ms |
208 KB |
Output is correct |
11 |
Correct |
4 ms |
208 KB |
Output is correct |
12 |
Correct |
5 ms |
208 KB |
Output is correct |
13 |
Correct |
6 ms |
208 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
5 ms |
208 KB |
Output is correct |
16 |
Correct |
3 ms |
208 KB |
Output is correct |
17 |
Correct |
5 ms |
208 KB |
Output is correct |
18 |
Correct |
4 ms |
304 KB |
Output is correct |
19 |
Correct |
5 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
5 ms |
208 KB |
Output is correct |
22 |
Correct |
3 ms |
208 KB |
Output is correct |
23 |
Correct |
9 ms |
336 KB |
Output is correct |
24 |
Correct |
14 ms |
336 KB |
Output is correct |
25 |
Correct |
20 ms |
336 KB |
Output is correct |
26 |
Correct |
20 ms |
316 KB |
Output is correct |
27 |
Correct |
20 ms |
312 KB |
Output is correct |
28 |
Correct |
17 ms |
316 KB |
Output is correct |
29 |
Correct |
20 ms |
324 KB |
Output is correct |
30 |
Correct |
19 ms |
340 KB |
Output is correct |
31 |
Correct |
18 ms |
336 KB |
Output is correct |
32 |
Correct |
15 ms |
324 KB |
Output is correct |
33 |
Correct |
24 ms |
324 KB |
Output is correct |
34 |
Correct |
15 ms |
336 KB |
Output is correct |
35 |
Correct |
21 ms |
328 KB |
Output is correct |
36 |
Correct |
24 ms |
320 KB |
Output is correct |
37 |
Correct |
16 ms |
320 KB |
Output is correct |
38 |
Correct |
22 ms |
336 KB |
Output is correct |
39 |
Correct |
23 ms |
332 KB |
Output is correct |
40 |
Correct |
19 ms |
300 KB |
Output is correct |
41 |
Correct |
13 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
22 ms |
328 KB |
Output is correct |
8 |
Correct |
30 ms |
388 KB |
Output is correct |
9 |
Correct |
21 ms |
344 KB |
Output is correct |
10 |
Correct |
39 ms |
376 KB |
Output is correct |
11 |
Correct |
43 ms |
332 KB |
Output is correct |
12 |
Correct |
38 ms |
336 KB |
Output is correct |
13 |
Correct |
37 ms |
360 KB |
Output is correct |
14 |
Correct |
45 ms |
480 KB |
Output is correct |
15 |
Correct |
40 ms |
380 KB |
Output is correct |
16 |
Correct |
37 ms |
352 KB |
Output is correct |
17 |
Correct |
32 ms |
360 KB |
Output is correct |
18 |
Correct |
33 ms |
372 KB |
Output is correct |
19 |
Correct |
41 ms |
336 KB |
Output is correct |
20 |
Correct |
35 ms |
336 KB |
Output is correct |
21 |
Correct |
21 ms |
392 KB |
Output is correct |
22 |
Correct |
26 ms |
376 KB |
Output is correct |
23 |
Correct |
40 ms |
336 KB |
Output is correct |
24 |
Correct |
30 ms |
352 KB |
Output is correct |
25 |
Correct |
29 ms |
376 KB |
Output is correct |
26 |
Correct |
23 ms |
340 KB |
Output is correct |
27 |
Correct |
39 ms |
364 KB |
Output is correct |
28 |
Correct |
28 ms |
456 KB |
Output is correct |
29 |
Partially correct |
23 ms |
336 KB |
Output is partially correct |
30 |
Partially correct |
38 ms |
348 KB |
Output is partially correct |
31 |
Correct |
44 ms |
456 KB |
Output is correct |
32 |
Correct |
50 ms |
372 KB |
Output is correct |
33 |
Correct |
28 ms |
380 KB |
Output is correct |
34 |
Correct |
34 ms |
352 KB |
Output is correct |
35 |
Partially correct |
48 ms |
336 KB |
Output is partially correct |
36 |
Correct |
39 ms |
352 KB |
Output is correct |
37 |
Correct |
38 ms |
368 KB |
Output is correct |
38 |
Correct |
39 ms |
336 KB |
Output is correct |
39 |
Correct |
45 ms |
376 KB |
Output is correct |
40 |
Correct |
25 ms |
368 KB |
Output is correct |
41 |
Correct |
47 ms |
336 KB |
Output is correct |
42 |
Partially correct |
39 ms |
376 KB |
Output is partially correct |
43 |
Correct |
8 ms |
208 KB |
Output is correct |
44 |
Correct |
30 ms |
304 KB |
Output is correct |
45 |
Correct |
28 ms |
440 KB |
Output is correct |
46 |
Correct |
33 ms |
368 KB |
Output is correct |
47 |
Correct |
22 ms |
348 KB |
Output is correct |
48 |
Correct |
35 ms |
328 KB |
Output is correct |