# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
535486 | 2022-03-10T11:19:55 Z | Baray | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 443 ms | 159368 KB |
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define int long long #define N 10000005 int sieve[N], cost[N]; int n, q; signed main() { cin >> n >> q; vector<int> a(n); int child, l = 1, mx = 0, p; for (int i = 0; i < n; i++) { cin >> p; mx = max(mx, p); for (int j = p; j < N; j += p) { sieve[j] = p; } } int cur = mx, next = 0, cur_cost = 1; for (int i = 0; i < N; i++) { if (i >= cur) { if (next > cur) { cur = next; cur_cost++; } else break; } cost[i] = cur_cost; if (sieve[i]) next = max(next, i + sieve[i]); } while (q--) { cin >> p; if (cost[p] == 0) { cout << "oo\n"; continue; } cout << cost[p] << "\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 78540 KB | Output is correct |
2 | Correct | 147 ms | 156808 KB | Output is correct |
3 | Correct | 64 ms | 80620 KB | Output is correct |
4 | Correct | 97 ms | 156876 KB | Output is correct |
5 | Correct | 108 ms | 156796 KB | Output is correct |
6 | Correct | 41 ms | 78576 KB | Output is correct |
7 | Correct | 54 ms | 80544 KB | Output is correct |
8 | Correct | 71 ms | 85612 KB | Output is correct |
9 | Correct | 138 ms | 156780 KB | Output is correct |
10 | Correct | 137 ms | 156804 KB | Output is correct |
11 | Correct | 146 ms | 156820 KB | Output is correct |
12 | Correct | 79 ms | 156732 KB | Output is correct |
13 | Correct | 203 ms | 156792 KB | Output is correct |
14 | Correct | 228 ms | 156916 KB | Output is correct |
15 | Correct | 132 ms | 156780 KB | Output is correct |
16 | Correct | 106 ms | 156804 KB | Output is correct |
17 | Correct | 129 ms | 156844 KB | Output is correct |
18 | Correct | 99 ms | 156896 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 129 ms | 156904 KB | Output is correct |
2 | Correct | 161 ms | 158260 KB | Output is correct |
3 | Correct | 256 ms | 157772 KB | Output is correct |
4 | Correct | 140 ms | 156760 KB | Output is correct |
5 | Correct | 200 ms | 157496 KB | Output is correct |
6 | Correct | 110 ms | 156768 KB | Output is correct |
7 | Correct | 106 ms | 156928 KB | Output is correct |
8 | Correct | 159 ms | 156748 KB | Output is correct |
9 | Correct | 223 ms | 157900 KB | Output is correct |
10 | Correct | 249 ms | 157772 KB | Output is correct |
11 | Correct | 291 ms | 157340 KB | Output is correct |
12 | Correct | 153 ms | 156860 KB | Output is correct |
13 | Correct | 98 ms | 156872 KB | Output is correct |
14 | Correct | 150 ms | 156856 KB | Output is correct |
15 | Correct | 219 ms | 157408 KB | Output is correct |
16 | Correct | 142 ms | 158436 KB | Output is correct |
17 | Correct | 240 ms | 156844 KB | Output is correct |
18 | Correct | 243 ms | 158284 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 291 ms | 157956 KB | Output is correct |
2 | Correct | 319 ms | 157988 KB | Output is correct |
3 | Correct | 346 ms | 158064 KB | Output is correct |
4 | Correct | 313 ms | 157816 KB | Output is correct |
5 | Correct | 360 ms | 159324 KB | Output is correct |
6 | Correct | 365 ms | 157924 KB | Output is correct |
7 | Correct | 309 ms | 158896 KB | Output is correct |
8 | Correct | 286 ms | 157968 KB | Output is correct |
9 | Correct | 298 ms | 157956 KB | Output is correct |
10 | Correct | 198 ms | 157020 KB | Output is correct |
11 | Correct | 222 ms | 157112 KB | Output is correct |
12 | Correct | 233 ms | 157072 KB | Output is correct |
13 | Correct | 366 ms | 158232 KB | Output is correct |
14 | Correct | 326 ms | 158120 KB | Output is correct |
15 | Correct | 239 ms | 157156 KB | Output is correct |
16 | Correct | 309 ms | 157140 KB | Output is correct |
17 | Correct | 219 ms | 157524 KB | Output is correct |
18 | Correct | 305 ms | 157756 KB | Output is correct |
19 | Correct | 140 ms | 157036 KB | Output is correct |
20 | Correct | 344 ms | 158164 KB | Output is correct |
21 | Correct | 322 ms | 158156 KB | Output is correct |
22 | Correct | 443 ms | 159368 KB | Output is correct |
23 | Correct | 302 ms | 158240 KB | Output is correct |
24 | Correct | 277 ms | 157972 KB | Output is correct |
25 | Correct | 319 ms | 157888 KB | Output is correct |
26 | Correct | 337 ms | 157876 KB | Output is correct |
27 | Correct | 360 ms | 158820 KB | Output is correct |
28 | Correct | 313 ms | 157912 KB | Output is correct |
29 | Correct | 408 ms | 159324 KB | Output is correct |
30 | Correct | 418 ms | 158840 KB | Output is correct |
31 | Correct | 273 ms | 157768 KB | Output is correct |
32 | Correct | 303 ms | 157860 KB | Output is correct |
33 | Correct | 233 ms | 157752 KB | Output is correct |
34 | Correct | 341 ms | 158904 KB | Output is correct |
35 | Correct | 280 ms | 158028 KB | Output is correct |
36 | Correct | 441 ms | 159148 KB | Output is correct |
37 | Correct | 319 ms | 159356 KB | Output is correct |
38 | Correct | 356 ms | 157908 KB | Output is correct |
39 | Correct | 279 ms | 157888 KB | Output is correct |
40 | Correct | 334 ms | 157932 KB | Output is correct |
41 | Correct | 280 ms | 159020 KB | Output is correct |
42 | Correct | 403 ms | 158044 KB | Output is correct |