#include <iostream>
#include <vector>
using namespace std;
const int MAXM = 100007, MAXV = 10000007;
int Q, M;
int A[MAXV];
vector<int> primes[MAXV];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> M >> Q;
for (int i = 0; i < M; ++i) {
int p;
cin >> p;
primes[0].push_back(p);
}
int r = 1;
for (int x = 0; r < MAXV && x < r; ++x) {
for (int p : primes[x]) {
for (; r < x + p && r < MAXV; ++r) A[r] = A[x] + 1;
if (x + p < MAXV) primes[x + p].push_back(p);
}
primes[x].clear();
primes[x].shrink_to_fit();
}
for (int q = 0; q < Q; ++q) {
int x;
cin >> x;
if (x >= r) cout << "oo\n";
else cout << A[x] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
216 ms |
235136 KB |
Output is correct |
2 |
Runtime error |
647 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Correct |
241 ms |
236180 KB |
Output is correct |
4 |
Runtime error |
316 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Runtime error |
397 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
6 |
Correct |
234 ms |
235288 KB |
Output is correct |
7 |
Correct |
240 ms |
236284 KB |
Output is correct |
8 |
Correct |
282 ms |
238840 KB |
Output is correct |
9 |
Runtime error |
820 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Runtime error |
937 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
11 |
Runtime error |
703 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
12 |
Runtime error |
290 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
13 |
Execution timed out |
1099 ms |
259028 KB |
Time limit exceeded |
14 |
Execution timed out |
1088 ms |
258608 KB |
Time limit exceeded |
15 |
Runtime error |
645 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
16 |
Runtime error |
642 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
17 |
Runtime error |
418 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
18 |
Runtime error |
310 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
467 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Runtime error |
253 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Execution timed out |
1096 ms |
257748 KB |
Time limit exceeded |
4 |
Runtime error |
552 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Runtime error |
931 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
6 |
Runtime error |
553 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Runtime error |
392 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Runtime error |
531 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
9 |
Runtime error |
1008 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Execution timed out |
1081 ms |
257096 KB |
Time limit exceeded |
11 |
Execution timed out |
1097 ms |
257784 KB |
Time limit exceeded |
12 |
Runtime error |
833 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
13 |
Runtime error |
381 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
14 |
Runtime error |
551 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
15 |
Execution timed out |
1101 ms |
259868 KB |
Time limit exceeded |
16 |
Runtime error |
234 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
17 |
Execution timed out |
1091 ms |
258564 KB |
Time limit exceeded |
18 |
Runtime error |
953 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1093 ms |
260252 KB |
Time limit exceeded |
2 |
Execution timed out |
1100 ms |
256996 KB |
Time limit exceeded |
3 |
Execution timed out |
1102 ms |
255896 KB |
Time limit exceeded |
4 |
Runtime error |
1016 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Runtime error |
371 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
6 |
Execution timed out |
1087 ms |
260680 KB |
Time limit exceeded |
7 |
Runtime error |
735 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Execution timed out |
1075 ms |
259080 KB |
Time limit exceeded |
9 |
Execution timed out |
1100 ms |
260248 KB |
Time limit exceeded |
10 |
Runtime error |
891 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
11 |
Runtime error |
714 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
12 |
Execution timed out |
1108 ms |
261792 KB |
Time limit exceeded |
13 |
Execution timed out |
1100 ms |
258680 KB |
Time limit exceeded |
14 |
Runtime error |
930 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
15 |
Execution timed out |
1110 ms |
258808 KB |
Time limit exceeded |
16 |
Execution timed out |
1105 ms |
257516 KB |
Time limit exceeded |
17 |
Runtime error |
1034 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
18 |
Execution timed out |
1079 ms |
256216 KB |
Time limit exceeded |
19 |
Runtime error |
449 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
20 |
Execution timed out |
1093 ms |
257224 KB |
Time limit exceeded |
21 |
Execution timed out |
1044 ms |
262148 KB |
Time limit exceeded |
22 |
Execution timed out |
1066 ms |
259352 KB |
Time limit exceeded |
23 |
Runtime error |
498 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
24 |
Runtime error |
404 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
25 |
Runtime error |
904 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
26 |
Runtime error |
895 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
27 |
Execution timed out |
1064 ms |
257968 KB |
Time limit exceeded |
28 |
Runtime error |
483 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
29 |
Execution timed out |
1029 ms |
262148 KB |
Time limit exceeded |
30 |
Runtime error |
974 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
31 |
Runtime error |
513 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
32 |
Runtime error |
603 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
33 |
Runtime error |
322 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
34 |
Runtime error |
690 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
35 |
Runtime error |
494 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
36 |
Execution timed out |
1087 ms |
260284 KB |
Time limit exceeded |
37 |
Runtime error |
358 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
38 |
Execution timed out |
1083 ms |
260528 KB |
Time limit exceeded |
39 |
Runtime error |
435 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
40 |
Runtime error |
1026 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
41 |
Runtime error |
235 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
42 |
Execution timed out |
1055 ms |
256256 KB |
Time limit exceeded |