#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 1e7+5;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll m, q;
ll p[(int)1e5 + 5];
int ans[MAXN];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
#ifdef Local
freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
#endif
cin>>m>>q;
memset(ans, 0x7f, sizeof(ans));
for(int i = 0; i < m; i++){
cin>>p[i];
}
for(int i = 1; i < p[m - 1]; i++){
ans[i] = 1;
}
for(int i = p[m - 1]; i <= 1e7; i++){
for(int j = m - 1; j >= 0; j--){
if(i % p[j] == 0) continue;
ans[i] = min(ans[i - i % p[j]] + 1, ans[i]);
break;
}
}
for(int i = 0; i < q; i++){
int n;
cin>>n;
if(ans[n] > 1e7){
cout<<"oo"<<endl;
}else{
cout<<ans[n]<<endl;
}
}
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
111 ms |
39552 KB |
Output isn't correct |
2 |
Incorrect |
101 ms |
39424 KB |
Output isn't correct |
3 |
Incorrect |
108 ms |
39416 KB |
Output isn't correct |
4 |
Incorrect |
92 ms |
39544 KB |
Output isn't correct |
5 |
Incorrect |
105 ms |
39416 KB |
Output isn't correct |
6 |
Incorrect |
112 ms |
39544 KB |
Output isn't correct |
7 |
Incorrect |
107 ms |
39424 KB |
Output isn't correct |
8 |
Incorrect |
108 ms |
39424 KB |
Output isn't correct |
9 |
Incorrect |
106 ms |
39416 KB |
Output isn't correct |
10 |
Incorrect |
101 ms |
39544 KB |
Output isn't correct |
11 |
Incorrect |
104 ms |
39544 KB |
Output isn't correct |
12 |
Correct |
94 ms |
39424 KB |
Output is correct |
13 |
Incorrect |
89 ms |
39552 KB |
Output isn't correct |
14 |
Incorrect |
91 ms |
39552 KB |
Output isn't correct |
15 |
Incorrect |
99 ms |
39544 KB |
Output isn't correct |
16 |
Incorrect |
100 ms |
39416 KB |
Output isn't correct |
17 |
Incorrect |
100 ms |
39672 KB |
Output isn't correct |
18 |
Incorrect |
93 ms |
39552 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
75 ms |
39680 KB |
Output isn't correct |
2 |
Correct |
42 ms |
40704 KB |
Output is correct |
3 |
Correct |
72 ms |
40568 KB |
Output is correct |
4 |
Incorrect |
83 ms |
39544 KB |
Output isn't correct |
5 |
Correct |
76 ms |
40192 KB |
Output is correct |
6 |
Incorrect |
85 ms |
39424 KB |
Output isn't correct |
7 |
Incorrect |
77 ms |
39680 KB |
Output isn't correct |
8 |
Incorrect |
90 ms |
39552 KB |
Output isn't correct |
9 |
Incorrect |
78 ms |
40568 KB |
Output isn't correct |
10 |
Correct |
71 ms |
40568 KB |
Output is correct |
11 |
Incorrect |
77 ms |
40104 KB |
Output isn't correct |
12 |
Incorrect |
85 ms |
39552 KB |
Output isn't correct |
13 |
Incorrect |
78 ms |
39552 KB |
Output isn't correct |
14 |
Incorrect |
83 ms |
39572 KB |
Output isn't correct |
15 |
Incorrect |
82 ms |
40060 KB |
Output isn't correct |
16 |
Correct |
41 ms |
40696 KB |
Output is correct |
17 |
Incorrect |
83 ms |
39552 KB |
Output isn't correct |
18 |
Incorrect |
61 ms |
40824 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
91 ms |
40548 KB |
Output isn't correct |
2 |
Incorrect |
90 ms |
40440 KB |
Output isn't correct |
3 |
Incorrect |
88 ms |
40548 KB |
Output isn't correct |
4 |
Incorrect |
111 ms |
40440 KB |
Output isn't correct |
5 |
Incorrect |
91 ms |
40952 KB |
Output isn't correct |
6 |
Incorrect |
113 ms |
40440 KB |
Output isn't correct |
7 |
Incorrect |
83 ms |
40832 KB |
Output isn't correct |
8 |
Incorrect |
90 ms |
40548 KB |
Output isn't correct |
9 |
Incorrect |
92 ms |
40572 KB |
Output isn't correct |
10 |
Incorrect |
91 ms |
39672 KB |
Output isn't correct |
11 |
Incorrect |
94 ms |
39800 KB |
Output isn't correct |
12 |
Incorrect |
93 ms |
39820 KB |
Output isn't correct |
13 |
Incorrect |
95 ms |
40568 KB |
Output isn't correct |
14 |
Incorrect |
133 ms |
40568 KB |
Output isn't correct |
15 |
Incorrect |
99 ms |
39800 KB |
Output isn't correct |
16 |
Incorrect |
91 ms |
39800 KB |
Output isn't correct |
17 |
Incorrect |
90 ms |
40312 KB |
Output isn't correct |
18 |
Incorrect |
97 ms |
40444 KB |
Output isn't correct |
19 |
Incorrect |
83 ms |
39812 KB |
Output isn't correct |
20 |
Incorrect |
90 ms |
40568 KB |
Output isn't correct |
21 |
Incorrect |
114 ms |
40696 KB |
Output isn't correct |
22 |
Incorrect |
107 ms |
41080 KB |
Output isn't correct |
23 |
Incorrect |
104 ms |
40516 KB |
Output isn't correct |
24 |
Incorrect |
114 ms |
40568 KB |
Output isn't correct |
25 |
Incorrect |
114 ms |
40440 KB |
Output isn't correct |
26 |
Incorrect |
116 ms |
40344 KB |
Output isn't correct |
27 |
Incorrect |
89 ms |
40832 KB |
Output isn't correct |
28 |
Incorrect |
100 ms |
40440 KB |
Output isn't correct |
29 |
Incorrect |
109 ms |
41080 KB |
Output isn't correct |
30 |
Incorrect |
115 ms |
40952 KB |
Output isn't correct |
31 |
Incorrect |
106 ms |
40312 KB |
Output isn't correct |
32 |
Incorrect |
113 ms |
40440 KB |
Output isn't correct |
33 |
Incorrect |
110 ms |
40312 KB |
Output isn't correct |
34 |
Incorrect |
81 ms |
40832 KB |
Output isn't correct |
35 |
Incorrect |
100 ms |
40440 KB |
Output isn't correct |
36 |
Incorrect |
109 ms |
40952 KB |
Output isn't correct |
37 |
Incorrect |
86 ms |
40952 KB |
Output isn't correct |
38 |
Incorrect |
115 ms |
40440 KB |
Output isn't correct |
39 |
Incorrect |
115 ms |
40440 KB |
Output isn't correct |
40 |
Incorrect |
110 ms |
40440 KB |
Output isn't correct |
41 |
Correct |
59 ms |
40832 KB |
Output is correct |
42 |
Incorrect |
104 ms |
40440 KB |
Output isn't correct |