#include <iostream>
#include <vector>
using namespace std;
const int MAXM = 100007, MAXV = 100007;
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 |
5 ms |
2676 KB |
Output is correct |
2 |
Correct |
11 ms |
3064 KB |
Output is correct |
3 |
Correct |
10 ms |
3064 KB |
Output is correct |
4 |
Correct |
8 ms |
3064 KB |
Output is correct |
5 |
Correct |
7 ms |
3064 KB |
Output is correct |
6 |
Correct |
5 ms |
2680 KB |
Output is correct |
7 |
Correct |
10 ms |
3068 KB |
Output is correct |
8 |
Correct |
12 ms |
3064 KB |
Output is correct |
9 |
Correct |
14 ms |
3064 KB |
Output is correct |
10 |
Correct |
16 ms |
3064 KB |
Output is correct |
11 |
Correct |
12 ms |
3064 KB |
Output is correct |
12 |
Correct |
5 ms |
3064 KB |
Output is correct |
13 |
Correct |
19 ms |
3192 KB |
Output is correct |
14 |
Correct |
20 ms |
3192 KB |
Output is correct |
15 |
Correct |
11 ms |
3064 KB |
Output is correct |
16 |
Correct |
11 ms |
3064 KB |
Output is correct |
17 |
Correct |
10 ms |
3192 KB |
Output is correct |
18 |
Correct |
8 ms |
3064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
3236 KB |
Output isn't correct |
2 |
Incorrect |
18 ms |
3572 KB |
Output isn't correct |
3 |
Incorrect |
16 ms |
3572 KB |
Output isn't correct |
4 |
Incorrect |
6 ms |
3192 KB |
Output isn't correct |
5 |
Incorrect |
13 ms |
3468 KB |
Output isn't correct |
6 |
Incorrect |
6 ms |
3064 KB |
Output isn't correct |
7 |
Incorrect |
6 ms |
3192 KB |
Output isn't correct |
8 |
Incorrect |
7 ms |
3064 KB |
Output isn't correct |
9 |
Incorrect |
15 ms |
3700 KB |
Output isn't correct |
10 |
Incorrect |
14 ms |
3572 KB |
Output isn't correct |
11 |
Incorrect |
10 ms |
3576 KB |
Output isn't correct |
12 |
Incorrect |
10 ms |
3192 KB |
Output isn't correct |
13 |
Incorrect |
5 ms |
3192 KB |
Output isn't correct |
14 |
Incorrect |
7 ms |
3192 KB |
Output isn't correct |
15 |
Incorrect |
10 ms |
3448 KB |
Output isn't correct |
16 |
Incorrect |
16 ms |
3572 KB |
Output isn't correct |
17 |
Incorrect |
14 ms |
3192 KB |
Output isn't correct |
18 |
Incorrect |
17 ms |
3696 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
3448 KB |
Output isn't correct |
2 |
Incorrect |
15 ms |
3576 KB |
Output isn't correct |
3 |
Incorrect |
20 ms |
3628 KB |
Output isn't correct |
4 |
Incorrect |
23 ms |
3536 KB |
Output isn't correct |
5 |
Incorrect |
33 ms |
3576 KB |
Output isn't correct |
6 |
Incorrect |
20 ms |
3576 KB |
Output isn't correct |
7 |
Incorrect |
25 ms |
3696 KB |
Output isn't correct |
8 |
Incorrect |
17 ms |
3448 KB |
Output isn't correct |
9 |
Incorrect |
17 ms |
3448 KB |
Output isn't correct |
10 |
Incorrect |
11 ms |
3320 KB |
Output isn't correct |
11 |
Incorrect |
11 ms |
3280 KB |
Output isn't correct |
12 |
Incorrect |
15 ms |
3320 KB |
Output isn't correct |
13 |
Incorrect |
23 ms |
3704 KB |
Output isn't correct |
14 |
Incorrect |
32 ms |
3320 KB |
Output isn't correct |
15 |
Incorrect |
16 ms |
3396 KB |
Output isn't correct |
16 |
Incorrect |
16 ms |
3320 KB |
Output isn't correct |
17 |
Incorrect |
12 ms |
3448 KB |
Output isn't correct |
18 |
Incorrect |
15 ms |
3576 KB |
Output isn't correct |
19 |
Incorrect |
8 ms |
3192 KB |
Output isn't correct |
20 |
Incorrect |
19 ms |
3576 KB |
Output isn't correct |
21 |
Incorrect |
31 ms |
3320 KB |
Output isn't correct |
22 |
Incorrect |
32 ms |
3696 KB |
Output isn't correct |
23 |
Incorrect |
23 ms |
3572 KB |
Output isn't correct |
24 |
Incorrect |
20 ms |
3448 KB |
Output isn't correct |
25 |
Incorrect |
26 ms |
3448 KB |
Output isn't correct |
26 |
Incorrect |
24 ms |
3448 KB |
Output isn't correct |
27 |
Incorrect |
27 ms |
3828 KB |
Output isn't correct |
28 |
Incorrect |
20 ms |
3448 KB |
Output isn't correct |
29 |
Incorrect |
33 ms |
3700 KB |
Output isn't correct |
30 |
Incorrect |
29 ms |
3696 KB |
Output isn't correct |
31 |
Incorrect |
18 ms |
3448 KB |
Output isn't correct |
32 |
Incorrect |
22 ms |
3448 KB |
Output isn't correct |
33 |
Incorrect |
19 ms |
3452 KB |
Output isn't correct |
34 |
Incorrect |
26 ms |
3700 KB |
Output isn't correct |
35 |
Incorrect |
21 ms |
3448 KB |
Output isn't correct |
36 |
Incorrect |
32 ms |
3700 KB |
Output isn't correct |
37 |
Incorrect |
32 ms |
3700 KB |
Output isn't correct |
38 |
Incorrect |
22 ms |
3704 KB |
Output isn't correct |
39 |
Incorrect |
20 ms |
3428 KB |
Output isn't correct |
40 |
Incorrect |
20 ms |
3576 KB |
Output isn't correct |
41 |
Incorrect |
26 ms |
3572 KB |
Output isn't correct |
42 |
Incorrect |
27 ms |
3448 KB |
Output isn't correct |