#include<bits/stdc++.h>
using namespace std;
const int M=10000000;
int x,m,q,d[M+5],a[M+5],b[M+5],p,pp,cnt;
int main()
{
cin>>m>>q;
for(int i=1;i<=m;++i)cin>>a[i];
for(int i=1;i<=m;++i)
for(int j=0;j<=M;j+=a[i])d[j]=max(d[j],a[i]);
for(int i=0;i<=M;++i)
{
while(i<=p&&i<=M)
{
if(d[i]!=0)pp=max(pp,i+d[i]-1);
b[i]=cnt;
if(i==p)break;
i++;
}
if(i==pp)break;
p=pp;
++cnt;
}
while(q--)
{
cin>>x;
if(b[x]==0&&x!=0)cout<<"oo\n";
else cout<<b[x]<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
119204 KB |
Output is correct |
2 |
Correct |
76 ms |
119204 KB |
Output is correct |
3 |
Correct |
43 ms |
119204 KB |
Output is correct |
4 |
Correct |
83 ms |
119204 KB |
Output is correct |
5 |
Correct |
83 ms |
119204 KB |
Output is correct |
6 |
Correct |
13 ms |
119204 KB |
Output is correct |
7 |
Correct |
26 ms |
119204 KB |
Output is correct |
8 |
Correct |
43 ms |
119204 KB |
Output is correct |
9 |
Correct |
113 ms |
119204 KB |
Output is correct |
10 |
Correct |
126 ms |
119204 KB |
Output is correct |
11 |
Correct |
153 ms |
119204 KB |
Output is correct |
12 |
Correct |
36 ms |
119204 KB |
Output is correct |
13 |
Correct |
296 ms |
119204 KB |
Output is correct |
14 |
Correct |
379 ms |
119204 KB |
Output is correct |
15 |
Correct |
109 ms |
119204 KB |
Output is correct |
16 |
Correct |
79 ms |
119204 KB |
Output is correct |
17 |
Correct |
113 ms |
119204 KB |
Output is correct |
18 |
Correct |
89 ms |
119204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
119204 KB |
Output is correct |
2 |
Correct |
133 ms |
119204 KB |
Output is correct |
3 |
Correct |
403 ms |
119204 KB |
Output is correct |
4 |
Correct |
149 ms |
119204 KB |
Output is correct |
5 |
Correct |
236 ms |
119204 KB |
Output is correct |
6 |
Correct |
83 ms |
119204 KB |
Output is correct |
7 |
Correct |
69 ms |
119204 KB |
Output is correct |
8 |
Correct |
126 ms |
119204 KB |
Output is correct |
9 |
Correct |
289 ms |
119204 KB |
Output is correct |
10 |
Correct |
393 ms |
119204 KB |
Output is correct |
11 |
Correct |
326 ms |
119204 KB |
Output is correct |
12 |
Correct |
189 ms |
119204 KB |
Output is correct |
13 |
Correct |
59 ms |
119204 KB |
Output is correct |
14 |
Correct |
123 ms |
119204 KB |
Output is correct |
15 |
Correct |
276 ms |
119204 KB |
Output is correct |
16 |
Correct |
136 ms |
119204 KB |
Output is correct |
17 |
Correct |
309 ms |
119204 KB |
Output is correct |
18 |
Correct |
333 ms |
119204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
466 ms |
119204 KB |
Output is correct |
2 |
Correct |
479 ms |
119204 KB |
Output is correct |
3 |
Runtime error |
503 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
4 |
Runtime error |
383 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
5 |
Runtime error |
269 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
6 |
Runtime error |
413 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
7 |
Correct |
329 ms |
119204 KB |
Output is correct |
8 |
Correct |
496 ms |
119204 KB |
Output is correct |
9 |
Correct |
333 ms |
119204 KB |
Output is correct |
10 |
Correct |
323 ms |
119204 KB |
Output is correct |
11 |
Correct |
276 ms |
119204 KB |
Output is correct |
12 |
Correct |
276 ms |
119204 KB |
Output is correct |
13 |
Runtime error |
486 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
14 |
Runtime error |
286 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
15 |
Correct |
303 ms |
119204 KB |
Output is correct |
16 |
Correct |
433 ms |
119204 KB |
Output is correct |
17 |
Correct |
339 ms |
119204 KB |
Output is correct |
18 |
Correct |
559 ms |
119204 KB |
Output is correct |
19 |
Correct |
163 ms |
119204 KB |
Output is correct |
20 |
Runtime error |
513 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
21 |
Runtime error |
316 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
22 |
Runtime error |
556 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
23 |
Runtime error |
259 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
24 |
Runtime error |
253 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
25 |
Runtime error |
379 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
26 |
Runtime error |
353 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
27 |
Runtime error |
586 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
28 |
Runtime error |
276 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
29 |
Runtime error |
616 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
30 |
Runtime error |
506 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
31 |
Runtime error |
356 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
32 |
Runtime error |
356 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
33 |
Runtime error |
209 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
34 |
Correct |
469 ms |
119204 KB |
Output is correct |
35 |
Runtime error |
283 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
36 |
Runtime error |
503 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
37 |
Runtime error |
339 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
38 |
Runtime error |
406 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
39 |
Runtime error |
223 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
40 |
Runtime error |
493 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
41 |
Runtime error |
429 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |
42 |
Runtime error |
486 ms |
119204 KB |
Execution timed out (wall clock limit exceeded) |