#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define el '\n'
#define ld long double
const int maxn=1e7+1,nn=1e5+1;
int f[maxn],oo,a[nn],n,m,q,p;
int take(int z){
if(f[z]>=0) return f[z];
f[z]=oo;
for(int i=0;i<m;++i) if(z%a[i]!=0) f[z]=min(f[z],take(z-z%a[i])+1);
return f[z];
}
int main(){
//freopen("T.INP","r",stdin);
//freopen("T.OUT","w",stdout);
ios_base::sync_with_stdio(0);cin.tie(0);
memset(f,-1,sizeof f);
oo=1e9;
f[0]=0;
cin >> m >> q;
for(int i=0;i<m;++i) cin >> a[i];
while(q--){
cin >> n;
p=take(n);
if(p>=oo) cout << 'o' << 'o' << el;
else cout << p << el;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
39372 KB |
Output is correct |
2 |
Correct |
17 ms |
39372 KB |
Output is correct |
3 |
Correct |
16 ms |
39404 KB |
Output is correct |
4 |
Correct |
23 ms |
39400 KB |
Output is correct |
5 |
Correct |
19 ms |
39400 KB |
Output is correct |
6 |
Correct |
15 ms |
39440 KB |
Output is correct |
7 |
Correct |
15 ms |
39500 KB |
Output is correct |
8 |
Correct |
15 ms |
39424 KB |
Output is correct |
9 |
Correct |
15 ms |
39372 KB |
Output is correct |
10 |
Correct |
19 ms |
39464 KB |
Output is correct |
11 |
Correct |
17 ms |
39500 KB |
Output is correct |
12 |
Correct |
16 ms |
39384 KB |
Output is correct |
13 |
Correct |
65 ms |
39644 KB |
Output is correct |
14 |
Correct |
66 ms |
39456 KB |
Output is correct |
15 |
Correct |
17 ms |
39372 KB |
Output is correct |
16 |
Correct |
22 ms |
39368 KB |
Output is correct |
17 |
Correct |
19 ms |
39372 KB |
Output is correct |
18 |
Correct |
21 ms |
39348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
43468 KB |
Time limit exceeded |
2 |
Execution timed out |
1096 ms |
59468 KB |
Time limit exceeded |
3 |
Execution timed out |
1086 ms |
163308 KB |
Time limit exceeded |
4 |
Execution timed out |
1061 ms |
71244 KB |
Time limit exceeded |
5 |
Execution timed out |
1092 ms |
76868 KB |
Time limit exceeded |
6 |
Execution timed out |
1098 ms |
51148 KB |
Time limit exceeded |
7 |
Execution timed out |
1092 ms |
43596 KB |
Time limit exceeded |
8 |
Execution timed out |
1093 ms |
51788 KB |
Time limit exceeded |
9 |
Execution timed out |
1091 ms |
66940 KB |
Time limit exceeded |
10 |
Execution timed out |
1106 ms |
163140 KB |
Time limit exceeded |
11 |
Runtime error |
205 ms |
262148 KB |
Execution killed with signal 9 |
12 |
Execution timed out |
1089 ms |
114924 KB |
Time limit exceeded |
13 |
Execution timed out |
1097 ms |
72864 KB |
Time limit exceeded |
14 |
Execution timed out |
1086 ms |
71280 KB |
Time limit exceeded |
15 |
Execution timed out |
1095 ms |
104244 KB |
Time limit exceeded |
16 |
Execution timed out |
1090 ms |
59716 KB |
Time limit exceeded |
17 |
Runtime error |
208 ms |
262148 KB |
Execution killed with signal 9 |
18 |
Execution timed out |
1103 ms |
212732 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
207 ms |
262148 KB |
Execution killed with signal 9 |
2 |
Execution timed out |
1087 ms |
52928 KB |
Time limit exceeded |
3 |
Execution timed out |
1097 ms |
223256 KB |
Time limit exceeded |
4 |
Execution timed out |
1065 ms |
148420 KB |
Time limit exceeded |
5 |
Execution timed out |
1091 ms |
40644 KB |
Time limit exceeded |
6 |
Execution timed out |
1104 ms |
208040 KB |
Time limit exceeded |
7 |
Execution timed out |
1076 ms |
75080 KB |
Time limit exceeded |
8 |
Runtime error |
199 ms |
262148 KB |
Execution killed with signal 9 |
9 |
Runtime error |
203 ms |
262148 KB |
Execution killed with signal 9 |
10 |
Execution timed out |
1085 ms |
47432 KB |
Time limit exceeded |
11 |
Execution timed out |
1095 ms |
84144 KB |
Time limit exceeded |
12 |
Execution timed out |
1104 ms |
169000 KB |
Time limit exceeded |
13 |
Execution timed out |
1094 ms |
127044 KB |
Time limit exceeded |
14 |
Execution timed out |
1098 ms |
195440 KB |
Time limit exceeded |
15 |
Runtime error |
197 ms |
262144 KB |
Execution killed with signal 9 |
16 |
Execution timed out |
1104 ms |
187060 KB |
Time limit exceeded |
17 |
Execution timed out |
1093 ms |
56256 KB |
Time limit exceeded |
18 |
Execution timed out |
1068 ms |
52932 KB |
Time limit exceeded |
19 |
Execution timed out |
1098 ms |
52684 KB |
Time limit exceeded |
20 |
Execution timed out |
1106 ms |
223292 KB |
Time limit exceeded |
21 |
Runtime error |
193 ms |
262148 KB |
Execution killed with signal 9 |
22 |
Execution timed out |
1096 ms |
226296 KB |
Time limit exceeded |
23 |
Execution timed out |
1087 ms |
40652 KB |
Time limit exceeded |
24 |
Execution timed out |
1098 ms |
48192 KB |
Time limit exceeded |
25 |
Execution timed out |
1088 ms |
45900 KB |
Time limit exceeded |
26 |
Execution timed out |
1097 ms |
148420 KB |
Time limit exceeded |
27 |
Execution timed out |
1104 ms |
223460 KB |
Time limit exceeded |
28 |
Execution timed out |
1098 ms |
87644 KB |
Time limit exceeded |
29 |
Execution timed out |
1095 ms |
93008 KB |
Time limit exceeded |
30 |
Execution timed out |
1101 ms |
68676 KB |
Time limit exceeded |
31 |
Execution timed out |
1092 ms |
74820 KB |
Time limit exceeded |
32 |
Execution timed out |
1084 ms |
77636 KB |
Time limit exceeded |
33 |
Execution timed out |
1094 ms |
48324 KB |
Time limit exceeded |
34 |
Execution timed out |
1080 ms |
75160 KB |
Time limit exceeded |
35 |
Execution timed out |
1102 ms |
54852 KB |
Time limit exceeded |
36 |
Execution timed out |
1093 ms |
70176 KB |
Time limit exceeded |
37 |
Execution timed out |
1088 ms |
40660 KB |
Time limit exceeded |
38 |
Execution timed out |
1107 ms |
207940 KB |
Time limit exceeded |
39 |
Execution timed out |
1096 ms |
47812 KB |
Time limit exceeded |
40 |
Execution timed out |
1103 ms |
102168 KB |
Time limit exceeded |
41 |
Execution timed out |
1097 ms |
93632 KB |
Time limit exceeded |
42 |
Runtime error |
194 ms |
262148 KB |
Execution killed with signal 9 |