#include <bits/stdc++.h>
#pragma GCC Optimize("O3")
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define MAXN 10000001
typedef long long ll;
using namespace std;
ll dp[MAXN], p[100001];
int main() {
iostream::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
FOR(i, 0, n) cin >> p[i];
fill(dp, dp + MAXN, -1);
dp[0] = 0;
FOR(i, 1, MAXN) {
int indx = n - 1;
while ((~indx) && i % p[indx] == 0) indx--;
if (indx == -1) break;
else dp[i] = dp[i - i % p[indx]] + 1;
}
FOR(i, 0, q) {
int x;
cin >> x;
if (dp[x] == -1) cout << "oo\n";
else cout << dp[x] << '\n';
}
return 0;
}
Compilation message
brunhilda.cpp:2:0: warning: ignoring #pragma GCC Optimize [-Wunknown-pragmas]
#pragma GCC Optimize("O3")
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
63 ms |
78584 KB |
Output isn't correct |
2 |
Incorrect |
188 ms |
78584 KB |
Output isn't correct |
3 |
Incorrect |
66 ms |
78584 KB |
Output isn't correct |
4 |
Incorrect |
189 ms |
78712 KB |
Output isn't correct |
5 |
Incorrect |
192 ms |
78712 KB |
Output isn't correct |
6 |
Incorrect |
62 ms |
78584 KB |
Output isn't correct |
7 |
Incorrect |
65 ms |
78584 KB |
Output isn't correct |
8 |
Incorrect |
74 ms |
78712 KB |
Output isn't correct |
9 |
Incorrect |
191 ms |
78664 KB |
Output isn't correct |
10 |
Incorrect |
190 ms |
78704 KB |
Output isn't correct |
11 |
Incorrect |
189 ms |
78584 KB |
Output isn't correct |
12 |
Correct |
187 ms |
78668 KB |
Output is correct |
13 |
Incorrect |
187 ms |
78712 KB |
Output isn't correct |
14 |
Incorrect |
189 ms |
78712 KB |
Output isn't correct |
15 |
Incorrect |
189 ms |
78660 KB |
Output isn't correct |
16 |
Incorrect |
189 ms |
78668 KB |
Output isn't correct |
17 |
Incorrect |
190 ms |
78712 KB |
Output isn't correct |
18 |
Incorrect |
189 ms |
78672 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
191 ms |
78968 KB |
Output isn't correct |
2 |
Correct |
200 ms |
80120 KB |
Output is correct |
3 |
Correct |
195 ms |
79608 KB |
Output is correct |
4 |
Incorrect |
188 ms |
78584 KB |
Output isn't correct |
5 |
Correct |
193 ms |
79480 KB |
Output is correct |
6 |
Incorrect |
199 ms |
78568 KB |
Output isn't correct |
7 |
Incorrect |
189 ms |
78740 KB |
Output isn't correct |
8 |
Incorrect |
191 ms |
78680 KB |
Output isn't correct |
9 |
Incorrect |
196 ms |
79596 KB |
Output isn't correct |
10 |
Correct |
197 ms |
79736 KB |
Output is correct |
11 |
Incorrect |
192 ms |
79220 KB |
Output isn't correct |
12 |
Incorrect |
189 ms |
78688 KB |
Output isn't correct |
13 |
Incorrect |
188 ms |
78712 KB |
Output isn't correct |
14 |
Incorrect |
188 ms |
78704 KB |
Output isn't correct |
15 |
Incorrect |
193 ms |
79224 KB |
Output isn't correct |
16 |
Correct |
200 ms |
80116 KB |
Output is correct |
17 |
Incorrect |
188 ms |
78712 KB |
Output isn't correct |
18 |
Incorrect |
199 ms |
80248 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
206 ms |
79808 KB |
Output isn't correct |
2 |
Incorrect |
204 ms |
79608 KB |
Output isn't correct |
3 |
Incorrect |
205 ms |
79940 KB |
Output isn't correct |
4 |
Incorrect |
216 ms |
79608 KB |
Output isn't correct |
5 |
Incorrect |
230 ms |
81084 KB |
Output isn't correct |
6 |
Incorrect |
219 ms |
79736 KB |
Output isn't correct |
7 |
Incorrect |
222 ms |
80764 KB |
Output isn't correct |
8 |
Incorrect |
219 ms |
79736 KB |
Output isn't correct |
9 |
Incorrect |
207 ms |
79804 KB |
Output isn't correct |
10 |
Incorrect |
192 ms |
78876 KB |
Output isn't correct |
11 |
Incorrect |
195 ms |
78968 KB |
Output isn't correct |
12 |
Incorrect |
196 ms |
78968 KB |
Output isn't correct |
13 |
Incorrect |
210 ms |
79976 KB |
Output isn't correct |
14 |
Incorrect |
209 ms |
79964 KB |
Output isn't correct |
15 |
Incorrect |
220 ms |
78984 KB |
Output isn't correct |
16 |
Incorrect |
196 ms |
78960 KB |
Output isn't correct |
17 |
Incorrect |
197 ms |
79416 KB |
Output isn't correct |
18 |
Incorrect |
203 ms |
79588 KB |
Output isn't correct |
19 |
Incorrect |
195 ms |
78840 KB |
Output isn't correct |
20 |
Incorrect |
204 ms |
79864 KB |
Output isn't correct |
21 |
Incorrect |
207 ms |
79992 KB |
Output isn't correct |
22 |
Incorrect |
233 ms |
81144 KB |
Output isn't correct |
23 |
Incorrect |
221 ms |
80248 KB |
Output isn't correct |
24 |
Incorrect |
219 ms |
79736 KB |
Output isn't correct |
25 |
Incorrect |
228 ms |
79760 KB |
Output isn't correct |
26 |
Incorrect |
217 ms |
79608 KB |
Output isn't correct |
27 |
Incorrect |
214 ms |
80588 KB |
Output isn't correct |
28 |
Incorrect |
226 ms |
79864 KB |
Output isn't correct |
29 |
Incorrect |
230 ms |
81144 KB |
Output isn't correct |
30 |
Incorrect |
226 ms |
80816 KB |
Output isn't correct |
31 |
Incorrect |
215 ms |
79740 KB |
Output isn't correct |
32 |
Incorrect |
223 ms |
79708 KB |
Output isn't correct |
33 |
Incorrect |
225 ms |
79696 KB |
Output isn't correct |
34 |
Incorrect |
211 ms |
80632 KB |
Output isn't correct |
35 |
Incorrect |
220 ms |
79864 KB |
Output isn't correct |
36 |
Incorrect |
296 ms |
80888 KB |
Output isn't correct |
37 |
Incorrect |
227 ms |
81116 KB |
Output isn't correct |
38 |
Incorrect |
240 ms |
79784 KB |
Output isn't correct |
39 |
Incorrect |
250 ms |
79896 KB |
Output isn't correct |
40 |
Incorrect |
239 ms |
79736 KB |
Output isn't correct |
41 |
Correct |
219 ms |
80856 KB |
Output is correct |
42 |
Incorrect |
209 ms |
80072 KB |
Output isn't correct |