#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];
int main() {
iostream::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
deque<int> dq;
FOR(i, 0, n) {
int k;
cin >> k;
dq.push_back(k);
}
dp[0] = 0;
FOR(i, 1, MAXN) {
dp[i] = INT_MAX;
for (int j = 0; j < n && i % dq.front() == 0; j++) {
dq.push_back(dq.front());
dq.pop_front();
}
dp[i] = dp[i - (i % dq.front())] + 1;
}
FOR(i, 0, q) {
int x;
cin >> x;
if (dp[x] >= INT_MAX) 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 |
Correct |
142 ms |
78600 KB |
Output is correct |
2 |
Incorrect |
118 ms |
78584 KB |
Output isn't correct |
3 |
Incorrect |
143 ms |
78644 KB |
Output isn't correct |
4 |
Incorrect |
119 ms |
78688 KB |
Output isn't correct |
5 |
Incorrect |
126 ms |
78720 KB |
Output isn't correct |
6 |
Correct |
141 ms |
78780 KB |
Output is correct |
7 |
Incorrect |
140 ms |
78584 KB |
Output isn't correct |
8 |
Incorrect |
141 ms |
78556 KB |
Output isn't correct |
9 |
Incorrect |
140 ms |
78584 KB |
Output isn't correct |
10 |
Incorrect |
127 ms |
78632 KB |
Output isn't correct |
11 |
Incorrect |
124 ms |
78564 KB |
Output isn't correct |
12 |
Correct |
117 ms |
78716 KB |
Output is correct |
13 |
Incorrect |
117 ms |
78656 KB |
Output isn't correct |
14 |
Correct |
119 ms |
78800 KB |
Output is correct |
15 |
Incorrect |
119 ms |
78584 KB |
Output isn't correct |
16 |
Incorrect |
120 ms |
78576 KB |
Output isn't correct |
17 |
Incorrect |
121 ms |
78648 KB |
Output isn't correct |
18 |
Incorrect |
118 ms |
78656 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
119 ms |
78816 KB |
Output isn't correct |
2 |
Correct |
131 ms |
79652 KB |
Output is correct |
3 |
Incorrect |
127 ms |
79388 KB |
Output isn't correct |
4 |
Incorrect |
117 ms |
78584 KB |
Output isn't correct |
5 |
Incorrect |
124 ms |
79316 KB |
Output isn't correct |
6 |
Incorrect |
119 ms |
78688 KB |
Output isn't correct |
7 |
Incorrect |
118 ms |
78776 KB |
Output isn't correct |
8 |
Incorrect |
117 ms |
78564 KB |
Output isn't correct |
9 |
Incorrect |
127 ms |
79352 KB |
Output isn't correct |
10 |
Incorrect |
126 ms |
79352 KB |
Output isn't correct |
11 |
Incorrect |
122 ms |
79088 KB |
Output isn't correct |
12 |
Incorrect |
116 ms |
78584 KB |
Output isn't correct |
13 |
Incorrect |
117 ms |
78584 KB |
Output isn't correct |
14 |
Incorrect |
119 ms |
78600 KB |
Output isn't correct |
15 |
Incorrect |
124 ms |
79096 KB |
Output isn't correct |
16 |
Correct |
130 ms |
79708 KB |
Output is correct |
17 |
Incorrect |
117 ms |
78648 KB |
Output isn't correct |
18 |
Incorrect |
131 ms |
79800 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
136 ms |
79600 KB |
Output isn't correct |
2 |
Incorrect |
131 ms |
79520 KB |
Output isn't correct |
3 |
Incorrect |
136 ms |
79832 KB |
Output isn't correct |
4 |
Incorrect |
146 ms |
79708 KB |
Output isn't correct |
5 |
Incorrect |
158 ms |
80896 KB |
Output isn't correct |
6 |
Incorrect |
148 ms |
79740 KB |
Output isn't correct |
7 |
Incorrect |
142 ms |
80444 KB |
Output isn't correct |
8 |
Incorrect |
137 ms |
79624 KB |
Output isn't correct |
9 |
Incorrect |
137 ms |
79768 KB |
Output isn't correct |
10 |
Incorrect |
134 ms |
78736 KB |
Output isn't correct |
11 |
Incorrect |
126 ms |
78876 KB |
Output isn't correct |
12 |
Incorrect |
124 ms |
78968 KB |
Output isn't correct |
13 |
Incorrect |
141 ms |
80016 KB |
Output isn't correct |
14 |
Incorrect |
146 ms |
80120 KB |
Output isn't correct |
15 |
Incorrect |
125 ms |
79024 KB |
Output isn't correct |
16 |
Incorrect |
124 ms |
78940 KB |
Output isn't correct |
17 |
Incorrect |
130 ms |
79260 KB |
Output isn't correct |
18 |
Incorrect |
133 ms |
79504 KB |
Output isn't correct |
19 |
Incorrect |
125 ms |
78924 KB |
Output isn't correct |
20 |
Incorrect |
134 ms |
79860 KB |
Output isn't correct |
21 |
Incorrect |
138 ms |
79968 KB |
Output isn't correct |
22 |
Incorrect |
163 ms |
81016 KB |
Output isn't correct |
23 |
Incorrect |
153 ms |
80132 KB |
Output isn't correct |
24 |
Incorrect |
148 ms |
79696 KB |
Output isn't correct |
25 |
Incorrect |
149 ms |
79736 KB |
Output isn't correct |
26 |
Incorrect |
146 ms |
79704 KB |
Output isn't correct |
27 |
Incorrect |
154 ms |
80440 KB |
Output isn't correct |
28 |
Incorrect |
137 ms |
79736 KB |
Output isn't correct |
29 |
Incorrect |
164 ms |
81032 KB |
Output isn't correct |
30 |
Incorrect |
160 ms |
80520 KB |
Output isn't correct |
31 |
Incorrect |
146 ms |
79608 KB |
Output isn't correct |
32 |
Incorrect |
147 ms |
79676 KB |
Output isn't correct |
33 |
Incorrect |
146 ms |
79660 KB |
Output isn't correct |
34 |
Incorrect |
144 ms |
80468 KB |
Output isn't correct |
35 |
Incorrect |
140 ms |
79828 KB |
Output isn't correct |
36 |
Incorrect |
163 ms |
80860 KB |
Output isn't correct |
37 |
Incorrect |
161 ms |
81016 KB |
Output isn't correct |
38 |
Incorrect |
150 ms |
79736 KB |
Output isn't correct |
39 |
Incorrect |
148 ms |
79748 KB |
Output isn't correct |
40 |
Incorrect |
147 ms |
79756 KB |
Output isn't correct |
41 |
Correct |
142 ms |
80280 KB |
Output is correct |
42 |
Incorrect |
137 ms |
80004 KB |
Output isn't correct |