#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e7;
ll m, q, x, u=N, a[N+5], b[N+5], j;
main(){
cin>>m>>q;
for (int i=1; i<=u+1; i++)a[i]=b[i]=u;
for (int i=1; i<=m&&!(j*=0); i++)
for (cin>>x; j+x-1<=u; j+=x)a[j+x-1]=min(a[j+x-1],j);
for (int i=u; i; i--)a[i]=min(a[i],a[i+1]);
for (int i=1; i<=u; i++)b[i]=b[a[i]]+1;
while(cin>>x)
if(b[x]<u)cout<<b[x]<<'\n';
else cout<<"oo\n";
}
Compilation message
brunhilda.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
156720 KB |
Output is correct |
2 |
Correct |
142 ms |
156836 KB |
Output is correct |
3 |
Correct |
131 ms |
156832 KB |
Output is correct |
4 |
Correct |
126 ms |
156952 KB |
Output is correct |
5 |
Correct |
130 ms |
156740 KB |
Output is correct |
6 |
Correct |
119 ms |
156776 KB |
Output is correct |
7 |
Correct |
130 ms |
156740 KB |
Output is correct |
8 |
Correct |
144 ms |
156832 KB |
Output is correct |
9 |
Correct |
165 ms |
156772 KB |
Output is correct |
10 |
Correct |
176 ms |
156832 KB |
Output is correct |
11 |
Correct |
165 ms |
156788 KB |
Output is correct |
12 |
Correct |
114 ms |
157008 KB |
Output is correct |
13 |
Correct |
269 ms |
156836 KB |
Output is correct |
14 |
Correct |
267 ms |
156820 KB |
Output is correct |
15 |
Correct |
170 ms |
156796 KB |
Output is correct |
16 |
Correct |
141 ms |
156760 KB |
Output is correct |
17 |
Correct |
145 ms |
156808 KB |
Output is correct |
18 |
Correct |
123 ms |
156784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
132 ms |
156952 KB |
Output is correct |
2 |
Correct |
167 ms |
157452 KB |
Output is correct |
3 |
Correct |
314 ms |
157376 KB |
Output is correct |
4 |
Correct |
149 ms |
156740 KB |
Output is correct |
5 |
Correct |
235 ms |
157272 KB |
Output is correct |
6 |
Correct |
141 ms |
156812 KB |
Output is correct |
7 |
Correct |
127 ms |
156908 KB |
Output is correct |
8 |
Correct |
147 ms |
156732 KB |
Output is correct |
9 |
Correct |
266 ms |
157224 KB |
Output is correct |
10 |
Correct |
315 ms |
157256 KB |
Output is correct |
11 |
Incorrect |
310 ms |
157000 KB |
Output isn't correct |
12 |
Correct |
184 ms |
156736 KB |
Output is correct |
13 |
Correct |
126 ms |
156844 KB |
Output is correct |
14 |
Correct |
151 ms |
156852 KB |
Output is correct |
15 |
Correct |
265 ms |
157060 KB |
Output is correct |
16 |
Correct |
161 ms |
157448 KB |
Output is correct |
17 |
Correct |
261 ms |
156848 KB |
Output is correct |
18 |
Correct |
278 ms |
157512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
329 ms |
157516 KB |
Output is correct |
2 |
Correct |
373 ms |
157508 KB |
Output is correct |
3 |
Correct |
394 ms |
157688 KB |
Output is correct |
4 |
Incorrect |
340 ms |
157776 KB |
Output isn't correct |
5 |
Incorrect |
321 ms |
158484 KB |
Output isn't correct |
6 |
Correct |
397 ms |
157896 KB |
Output is correct |
7 |
Correct |
322 ms |
158020 KB |
Output is correct |
8 |
Correct |
332 ms |
157644 KB |
Output is correct |
9 |
Correct |
328 ms |
157508 KB |
Output is correct |
10 |
Correct |
250 ms |
156876 KB |
Output is correct |
11 |
Incorrect |
215 ms |
157124 KB |
Output isn't correct |
12 |
Correct |
281 ms |
157004 KB |
Output is correct |
13 |
Correct |
437 ms |
157972 KB |
Output is correct |
14 |
Correct |
323 ms |
158100 KB |
Output is correct |
15 |
Incorrect |
292 ms |
157192 KB |
Output isn't correct |
16 |
Correct |
308 ms |
157104 KB |
Output is correct |
17 |
Correct |
267 ms |
157220 KB |
Output is correct |
18 |
Correct |
359 ms |
157512 KB |
Output is correct |
19 |
Incorrect |
162 ms |
156988 KB |
Output isn't correct |
20 |
Correct |
395 ms |
157764 KB |
Output is correct |
21 |
Incorrect |
357 ms |
158164 KB |
Output isn't correct |
22 |
Correct |
503 ms |
158692 KB |
Output is correct |
23 |
Correct |
302 ms |
158000 KB |
Output is correct |
24 |
Correct |
272 ms |
157792 KB |
Output is correct |
25 |
Incorrect |
367 ms |
157900 KB |
Output isn't correct |
26 |
Incorrect |
329 ms |
157720 KB |
Output isn't correct |
27 |
Correct |
434 ms |
158024 KB |
Output is correct |
28 |
Incorrect |
284 ms |
157892 KB |
Output isn't correct |
29 |
Correct |
458 ms |
158444 KB |
Output is correct |
30 |
Correct |
417 ms |
158268 KB |
Output is correct |
31 |
Correct |
277 ms |
157672 KB |
Output is correct |
32 |
Incorrect |
296 ms |
157800 KB |
Output isn't correct |
33 |
Incorrect |
253 ms |
157756 KB |
Output isn't correct |
34 |
Correct |
323 ms |
158020 KB |
Output is correct |
35 |
Incorrect |
282 ms |
157872 KB |
Output isn't correct |
36 |
Correct |
466 ms |
158412 KB |
Output is correct |
37 |
Incorrect |
317 ms |
158532 KB |
Output isn't correct |
38 |
Correct |
400 ms |
157776 KB |
Output is correct |
39 |
Incorrect |
289 ms |
157892 KB |
Output isn't correct |
40 |
Correct |
368 ms |
157820 KB |
Output is correct |
41 |
Correct |
315 ms |
158012 KB |
Output is correct |
42 |
Incorrect |
423 ms |
158104 KB |
Output isn't correct |