#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<=u+1; j+=x)a[j-1]=min(a[j-1],j-x);
for (int i=u; i; i--)a[u]=min(a[u],a[u+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(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
129 ms |
156744 KB |
Output isn't correct |
2 |
Incorrect |
141 ms |
156824 KB |
Output isn't correct |
3 |
Incorrect |
134 ms |
156796 KB |
Output isn't correct |
4 |
Incorrect |
135 ms |
156868 KB |
Output isn't correct |
5 |
Incorrect |
127 ms |
156828 KB |
Output isn't correct |
6 |
Incorrect |
115 ms |
156824 KB |
Output isn't correct |
7 |
Incorrect |
132 ms |
156788 KB |
Output isn't correct |
8 |
Incorrect |
146 ms |
156716 KB |
Output isn't correct |
9 |
Incorrect |
160 ms |
156728 KB |
Output isn't correct |
10 |
Incorrect |
195 ms |
156832 KB |
Output isn't correct |
11 |
Incorrect |
177 ms |
156824 KB |
Output isn't correct |
12 |
Incorrect |
105 ms |
156724 KB |
Output isn't correct |
13 |
Incorrect |
290 ms |
156788 KB |
Output isn't correct |
14 |
Incorrect |
310 ms |
156892 KB |
Output isn't correct |
15 |
Incorrect |
153 ms |
156824 KB |
Output isn't correct |
16 |
Incorrect |
140 ms |
156836 KB |
Output isn't correct |
17 |
Incorrect |
150 ms |
156740 KB |
Output isn't correct |
18 |
Incorrect |
130 ms |
156828 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
145 ms |
156832 KB |
Output isn't correct |
2 |
Incorrect |
190 ms |
156828 KB |
Output isn't correct |
3 |
Incorrect |
396 ms |
156868 KB |
Output isn't correct |
4 |
Incorrect |
154 ms |
156828 KB |
Output isn't correct |
5 |
Incorrect |
262 ms |
156868 KB |
Output isn't correct |
6 |
Incorrect |
156 ms |
156820 KB |
Output isn't correct |
7 |
Incorrect |
140 ms |
156740 KB |
Output isn't correct |
8 |
Incorrect |
146 ms |
156764 KB |
Output isn't correct |
9 |
Incorrect |
302 ms |
156904 KB |
Output isn't correct |
10 |
Incorrect |
365 ms |
156832 KB |
Output isn't correct |
11 |
Incorrect |
356 ms |
156868 KB |
Output isn't correct |
12 |
Incorrect |
192 ms |
156772 KB |
Output isn't correct |
13 |
Incorrect |
122 ms |
156788 KB |
Output isn't correct |
14 |
Incorrect |
170 ms |
156824 KB |
Output isn't correct |
15 |
Incorrect |
312 ms |
156824 KB |
Output isn't correct |
16 |
Incorrect |
185 ms |
156820 KB |
Output isn't correct |
17 |
Incorrect |
298 ms |
156836 KB |
Output isn't correct |
18 |
Incorrect |
329 ms |
156896 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
389 ms |
156996 KB |
Output isn't correct |
2 |
Incorrect |
409 ms |
156832 KB |
Output isn't correct |
3 |
Incorrect |
465 ms |
157208 KB |
Output isn't correct |
4 |
Incorrect |
368 ms |
157608 KB |
Output isn't correct |
5 |
Incorrect |
364 ms |
157764 KB |
Output isn't correct |
6 |
Incorrect |
458 ms |
157692 KB |
Output isn't correct |
7 |
Incorrect |
393 ms |
157192 KB |
Output isn't correct |
8 |
Incorrect |
409 ms |
157084 KB |
Output isn't correct |
9 |
Incorrect |
379 ms |
157092 KB |
Output isn't correct |
10 |
Incorrect |
255 ms |
156980 KB |
Output isn't correct |
11 |
Incorrect |
228 ms |
156908 KB |
Output isn't correct |
12 |
Incorrect |
303 ms |
157168 KB |
Output isn't correct |
13 |
Incorrect |
488 ms |
157612 KB |
Output isn't correct |
14 |
Incorrect |
345 ms |
157892 KB |
Output isn't correct |
15 |
Incorrect |
312 ms |
156992 KB |
Output isn't correct |
16 |
Incorrect |
349 ms |
157004 KB |
Output isn't correct |
17 |
Incorrect |
319 ms |
156856 KB |
Output isn't correct |
18 |
Incorrect |
426 ms |
156880 KB |
Output isn't correct |
19 |
Incorrect |
184 ms |
156968 KB |
Output isn't correct |
20 |
Incorrect |
473 ms |
157284 KB |
Output isn't correct |
21 |
Incorrect |
395 ms |
157820 KB |
Output isn't correct |
22 |
Incorrect |
559 ms |
157956 KB |
Output isn't correct |
23 |
Incorrect |
343 ms |
157724 KB |
Output isn't correct |
24 |
Incorrect |
328 ms |
157696 KB |
Output isn't correct |
25 |
Incorrect |
417 ms |
157752 KB |
Output isn't correct |
26 |
Incorrect |
389 ms |
157556 KB |
Output isn't correct |
27 |
Incorrect |
517 ms |
157252 KB |
Output isn't correct |
28 |
Incorrect |
325 ms |
157892 KB |
Output isn't correct |
29 |
Incorrect |
521 ms |
157636 KB |
Output isn't correct |
30 |
Incorrect |
488 ms |
157636 KB |
Output isn't correct |
31 |
Incorrect |
301 ms |
157640 KB |
Output isn't correct |
32 |
Incorrect |
334 ms |
157728 KB |
Output isn't correct |
33 |
Incorrect |
283 ms |
157684 KB |
Output isn't correct |
34 |
Incorrect |
419 ms |
157228 KB |
Output isn't correct |
35 |
Incorrect |
317 ms |
157828 KB |
Output isn't correct |
36 |
Incorrect |
553 ms |
157592 KB |
Output isn't correct |
37 |
Incorrect |
388 ms |
157728 KB |
Output isn't correct |
38 |
Incorrect |
443 ms |
157632 KB |
Output isn't correct |
39 |
Incorrect |
322 ms |
157764 KB |
Output isn't correct |
40 |
Incorrect |
388 ms |
157508 KB |
Output isn't correct |
41 |
Incorrect |
378 ms |
157380 KB |
Output isn't correct |
42 |
Incorrect |
463 ms |
157808 KB |
Output isn't correct |