# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
766903 | 2023-06-26T08:47:40 Z | birktj | Rarest Insects (IOI22_insects) | C++17 | 59 ms | 336 KB |
#include "insects.h" #include <stack> #include <algorithm> #include <iostream> using namespace std; stack<int> box, pile, discard; void fill_box(int x) { while (!pile.empty()) { int i = pile.top(); pile.pop(); move_inside(i); box.push(i); int maxCount = press_button(); if (maxCount > x) { move_outside(i); box.pop(); discard.push(i); } } } void empty_box() { while (!box.empty()) { int i = box.top(); box.pop(); move_outside(i); discard.push(i); } } int min_cardinality(int N) { for (int i = 0; i < N; i++) { pile.push(i); } fill_box(1); swap(discard, pile); int k = box.size(); empty_box(); discard = {}; //printCounts(); //cerr << "piles size = " << pile.size() << endl; //cerr << "discard size = " << discard.size() << endl; //cerr << "box size = " << box.size() << endl; int l = 1; int u = N/k; while (l + 1 <= u) { int m = (l + u + 1) / 2; //cerr << "m = " << m << endl; //cerr << "l = " << l << endl; fill_box(m - l); swap(discard, pile); empty_box(); //cerr << "piles size = " << pile.size() << endl; //cerr << "discard size = " << discard.size() << endl; //cerr << "discard size + extra = " << discard.size() + k*l << endl; //printCounts(); if (discard.size() + k*l == m*k) { discard = {}; l = m; } else { pile = {}; swap(discard, pile); u = m-1; } } return l; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 6 ms | 208 KB | Output is correct |
7 | Correct | 2 ms | 208 KB | Output is correct |
8 | Correct | 4 ms | 208 KB | Output is correct |
9 | Correct | 5 ms | 208 KB | Output is correct |
10 | Correct | 5 ms | 208 KB | Output is correct |
11 | Correct | 2 ms | 208 KB | Output is correct |
12 | Correct | 4 ms | 208 KB | Output is correct |
13 | Correct | 4 ms | 208 KB | Output is correct |
14 | Correct | 5 ms | 208 KB | Output is correct |
15 | Correct | 4 ms | 208 KB | Output is correct |
16 | Correct | 4 ms | 256 KB | Output is correct |
17 | Correct | 4 ms | 208 KB | Output is correct |
18 | Correct | 5 ms | 208 KB | Output is correct |
19 | Correct | 4 ms | 208 KB | Output is correct |
20 | Correct | 3 ms | 208 KB | Output is correct |
21 | Correct | 3 ms | 208 KB | Output is correct |
22 | Correct | 2 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 6 ms | 208 KB | Output is correct |
7 | Correct | 2 ms | 208 KB | Output is correct |
8 | Correct | 4 ms | 208 KB | Output is correct |
9 | Correct | 5 ms | 208 KB | Output is correct |
10 | Correct | 5 ms | 208 KB | Output is correct |
11 | Correct | 2 ms | 208 KB | Output is correct |
12 | Correct | 4 ms | 208 KB | Output is correct |
13 | Correct | 4 ms | 208 KB | Output is correct |
14 | Correct | 5 ms | 208 KB | Output is correct |
15 | Correct | 4 ms | 208 KB | Output is correct |
16 | Correct | 4 ms | 256 KB | Output is correct |
17 | Correct | 4 ms | 208 KB | Output is correct |
18 | Correct | 5 ms | 208 KB | Output is correct |
19 | Correct | 4 ms | 208 KB | Output is correct |
20 | Correct | 3 ms | 208 KB | Output is correct |
21 | Correct | 3 ms | 208 KB | Output is correct |
22 | Correct | 2 ms | 208 KB | Output is correct |
23 | Correct | 18 ms | 308 KB | Output is correct |
24 | Correct | 4 ms | 308 KB | Output is correct |
25 | Correct | 19 ms | 308 KB | Output is correct |
26 | Correct | 20 ms | 208 KB | Output is correct |
27 | Correct | 22 ms | 208 KB | Output is correct |
28 | Correct | 9 ms | 208 KB | Output is correct |
29 | Correct | 23 ms | 208 KB | Output is correct |
30 | Correct | 23 ms | 304 KB | Output is correct |
31 | Correct | 24 ms | 208 KB | Output is correct |
32 | Correct | 27 ms | 208 KB | Output is correct |
33 | Correct | 17 ms | 208 KB | Output is correct |
34 | Correct | 20 ms | 208 KB | Output is correct |
35 | Correct | 19 ms | 208 KB | Output is correct |
36 | Correct | 20 ms | 312 KB | Output is correct |
37 | Correct | 24 ms | 208 KB | Output is correct |
38 | Correct | 16 ms | 312 KB | Output is correct |
39 | Correct | 19 ms | 208 KB | Output is correct |
40 | Correct | 14 ms | 208 KB | Output is correct |
41 | Correct | 12 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 1 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 | 1 ms | 304 KB | Output is correct |
7 | Correct | 42 ms | 208 KB | Output is correct |
8 | Correct | 14 ms | 312 KB | Output is correct |
9 | Correct | 51 ms | 296 KB | Output is correct |
10 | Correct | 40 ms | 292 KB | Output is correct |
11 | Correct | 19 ms | 304 KB | Output is correct |
12 | Correct | 28 ms | 316 KB | Output is correct |
13 | Correct | 20 ms | 308 KB | Output is correct |
14 | Correct | 51 ms | 292 KB | Output is correct |
15 | Correct | 35 ms | 208 KB | Output is correct |
16 | Correct | 21 ms | 208 KB | Output is correct |
17 | Correct | 54 ms | 296 KB | Output is correct |
18 | Correct | 41 ms | 292 KB | Output is correct |
19 | Partially correct | 53 ms | 208 KB | Output is partially correct |
20 | Correct | 42 ms | 336 KB | Output is correct |
21 | Correct | 59 ms | 296 KB | Output is correct |
22 | Correct | 48 ms | 292 KB | Output is correct |
23 | Correct | 22 ms | 208 KB | Output is correct |
24 | Correct | 40 ms | 208 KB | Output is correct |
25 | Correct | 28 ms | 296 KB | Output is correct |
26 | Correct | 9 ms | 316 KB | Output is correct |
27 | Correct | 47 ms | 308 KB | Output is correct |
28 | Correct | 43 ms | 296 KB | Output is correct |
29 | Partially correct | 53 ms | 208 KB | Output is partially correct |
30 | Partially correct | 45 ms | 288 KB | Output is partially correct |
31 | Correct | 32 ms | 208 KB | Output is correct |
32 | Correct | 46 ms | 208 KB | Output is correct |
33 | Correct | 49 ms | 292 KB | Output is correct |
34 | Correct | 40 ms | 208 KB | Output is correct |
35 | Partially correct | 32 ms | 312 KB | Output is partially correct |
36 | Partially correct | 49 ms | 208 KB | Output is partially correct |
37 | Correct | 47 ms | 292 KB | Output is correct |
38 | Correct | 44 ms | 296 KB | Output is correct |
39 | Correct | 38 ms | 296 KB | Output is correct |
40 | Correct | 48 ms | 208 KB | Output is correct |
41 | Partially correct | 51 ms | 208 KB | Output is partially correct |
42 | Partially correct | 46 ms | 296 KB | Output is partially correct |
43 | Correct | 11 ms | 208 KB | Output is correct |
44 | Correct | 21 ms | 208 KB | Output is correct |
45 | Correct | 42 ms | 288 KB | Output is correct |
46 | Correct | 27 ms | 292 KB | Output is correct |
47 | Correct | 18 ms | 208 KB | Output is correct |
48 | Correct | 25 ms | 208 KB | Output is correct |