#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,ans[20000001],a[20000001];
int32_t main(){
CODE_START
n=2e7;
cin>>m;
int q;
cin>>q;
for(int i=1;i<=m;i++)
{
ll x;
cin>>x;
for(int j=x;j<=n;j+=x){
a[j-1]=max(a[j-1],x-1);
}
}
for(int i=n;i>=1;i--)
{
a[i]=max(a[i],a[i+1]-1);
}
for(int i=1;i<=m;i++)
{
if(a[i]&&(ans[i-a[i]]||i-a[i]==0)){
ans[i]=ans[i-a[i]]+1;
}
}
while(q--){
int x;
cin>>x;
if(ans[x]){
cout<<ans[x]<<endl;
}else cout<<"oo"<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
181 ms |
157036 KB |
Output isn't correct |
2 |
Incorrect |
232 ms |
157060 KB |
Output isn't correct |
3 |
Incorrect |
192 ms |
156908 KB |
Output isn't correct |
4 |
Incorrect |
156 ms |
156908 KB |
Output isn't correct |
5 |
Incorrect |
195 ms |
157036 KB |
Output isn't correct |
6 |
Incorrect |
161 ms |
156908 KB |
Output isn't correct |
7 |
Incorrect |
192 ms |
156908 KB |
Output isn't correct |
8 |
Incorrect |
214 ms |
156908 KB |
Output isn't correct |
9 |
Incorrect |
271 ms |
156908 KB |
Output isn't correct |
10 |
Incorrect |
322 ms |
157036 KB |
Output isn't correct |
11 |
Incorrect |
308 ms |
156908 KB |
Output isn't correct |
12 |
Incorrect |
153 ms |
157036 KB |
Output isn't correct |
13 |
Incorrect |
550 ms |
156920 KB |
Output isn't correct |
14 |
Incorrect |
552 ms |
157036 KB |
Output isn't correct |
15 |
Incorrect |
246 ms |
156908 KB |
Output isn't correct |
16 |
Incorrect |
238 ms |
157036 KB |
Output isn't correct |
17 |
Incorrect |
210 ms |
157036 KB |
Output isn't correct |
18 |
Incorrect |
156 ms |
156908 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
193 ms |
156988 KB |
Output isn't correct |
2 |
Incorrect |
219 ms |
157676 KB |
Output isn't correct |
3 |
Incorrect |
707 ms |
157548 KB |
Output isn't correct |
4 |
Incorrect |
249 ms |
156908 KB |
Output isn't correct |
5 |
Incorrect |
446 ms |
157548 KB |
Output isn't correct |
6 |
Incorrect |
208 ms |
156908 KB |
Output isn't correct |
7 |
Incorrect |
199 ms |
157036 KB |
Output isn't correct |
8 |
Incorrect |
245 ms |
156916 KB |
Output isn't correct |
9 |
Incorrect |
518 ms |
157400 KB |
Output isn't correct |
10 |
Incorrect |
689 ms |
157468 KB |
Output isn't correct |
11 |
Incorrect |
661 ms |
157184 KB |
Output isn't correct |
12 |
Incorrect |
358 ms |
157036 KB |
Output isn't correct |
13 |
Incorrect |
179 ms |
156908 KB |
Output isn't correct |
14 |
Incorrect |
265 ms |
156908 KB |
Output isn't correct |
15 |
Incorrect |
540 ms |
157164 KB |
Output isn't correct |
16 |
Incorrect |
237 ms |
157748 KB |
Output isn't correct |
17 |
Incorrect |
561 ms |
157036 KB |
Output isn't correct |
18 |
Incorrect |
532 ms |
157804 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
556 ms |
157548 KB |
Output isn't correct |
2 |
Incorrect |
697 ms |
157676 KB |
Output isn't correct |
3 |
Incorrect |
705 ms |
157664 KB |
Output isn't correct |
4 |
Incorrect |
392 ms |
157420 KB |
Output isn't correct |
5 |
Incorrect |
257 ms |
158060 KB |
Output isn't correct |
6 |
Incorrect |
550 ms |
157696 KB |
Output isn't correct |
7 |
Incorrect |
451 ms |
157804 KB |
Output isn't correct |
8 |
Incorrect |
548 ms |
157548 KB |
Output isn't correct |
9 |
Incorrect |
572 ms |
157468 KB |
Output isn't correct |
10 |
Incorrect |
429 ms |
157164 KB |
Output isn't correct |
11 |
Incorrect |
354 ms |
157192 KB |
Output isn't correct |
12 |
Incorrect |
529 ms |
157164 KB |
Output isn't correct |
13 |
Incorrect |
642 ms |
157548 KB |
Output isn't correct |
14 |
Incorrect |
368 ms |
157164 KB |
Output isn't correct |
15 |
Incorrect |
539 ms |
157292 KB |
Output isn't correct |
16 |
Incorrect |
612 ms |
157292 KB |
Output isn't correct |
17 |
Incorrect |
512 ms |
157576 KB |
Output isn't correct |
18 |
Incorrect |
709 ms |
157688 KB |
Output isn't correct |
19 |
Incorrect |
200 ms |
157164 KB |
Output isn't correct |
20 |
Incorrect |
694 ms |
157548 KB |
Output isn't correct |
21 |
Incorrect |
435 ms |
157292 KB |
Output isn't correct |
22 |
Incorrect |
701 ms |
158096 KB |
Output isn't correct |
23 |
Incorrect |
311 ms |
157548 KB |
Output isn't correct |
24 |
Incorrect |
234 ms |
157420 KB |
Output isn't correct |
25 |
Incorrect |
447 ms |
157420 KB |
Output isn't correct |
26 |
Incorrect |
480 ms |
157468 KB |
Output isn't correct |
27 |
Incorrect |
891 ms |
158152 KB |
Output isn't correct |
28 |
Incorrect |
237 ms |
157356 KB |
Output isn't correct |
29 |
Incorrect |
669 ms |
158124 KB |
Output isn't correct |
30 |
Incorrect |
632 ms |
157996 KB |
Output isn't correct |
31 |
Incorrect |
328 ms |
157456 KB |
Output isn't correct |
32 |
Incorrect |
319 ms |
157452 KB |
Output isn't correct |
33 |
Incorrect |
229 ms |
157548 KB |
Output isn't correct |
34 |
Incorrect |
513 ms |
157932 KB |
Output isn't correct |
35 |
Incorrect |
259 ms |
157388 KB |
Output isn't correct |
36 |
Incorrect |
777 ms |
158344 KB |
Output isn't correct |
37 |
Incorrect |
270 ms |
158152 KB |
Output isn't correct |
38 |
Incorrect |
670 ms |
157484 KB |
Output isn't correct |
39 |
Incorrect |
283 ms |
157464 KB |
Output isn't correct |
40 |
Incorrect |
568 ms |
157612 KB |
Output isn't correct |
41 |
Incorrect |
505 ms |
157932 KB |
Output isn't correct |
42 |
Incorrect |
693 ms |
157356 KB |
Output isn't correct |