#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll nx=1e4+5;
ll m, q, x, dp[nx];
vector<ll> p;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>m>>q;
for (int i=1; i<=m; i++) cin>>x, p.push_back(x);
for (int i=1; i<nx; i++) dp[i]=1e18;
for (int i=1; i<nx; i++) for (auto t:p) dp[i]=min(dp[i], dp[i-(i%t)]+1);
while (q--)
{
cin>>x;
if (dp[x]==1e18) cout<<"oo\n";
else cout<<dp[x]<<'\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
348 KB |
Output is correct |
13 |
Correct |
45 ms |
348 KB |
Output is correct |
14 |
Correct |
46 ms |
532 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
4 ms |
536 KB |
Output is correct |
18 |
Correct |
5 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
515 ms |
992 KB |
Execution killed with signal 11 |
2 |
Execution timed out |
1020 ms |
1496 KB |
Time limit exceeded |
3 |
Execution timed out |
1065 ms |
1500 KB |
Time limit exceeded |
4 |
Runtime error |
135 ms |
828 KB |
Execution killed with signal 11 |
5 |
Execution timed out |
1067 ms |
992 KB |
Time limit exceeded |
6 |
Runtime error |
52 ms |
596 KB |
Execution killed with signal 11 |
7 |
Runtime error |
515 ms |
988 KB |
Execution killed with signal 11 |
8 |
Runtime error |
46 ms |
592 KB |
Execution killed with signal 11 |
9 |
Execution timed out |
1071 ms |
1500 KB |
Time limit exceeded |
10 |
Execution timed out |
1012 ms |
1496 KB |
Time limit exceeded |
11 |
Execution timed out |
1054 ms |
992 KB |
Time limit exceeded |
12 |
Runtime error |
92 ms |
592 KB |
Execution killed with signal 11 |
13 |
Runtime error |
126 ms |
852 KB |
Execution killed with signal 11 |
14 |
Runtime error |
135 ms |
828 KB |
Execution killed with signal 11 |
15 |
Execution timed out |
1046 ms |
992 KB |
Time limit exceeded |
16 |
Execution timed out |
1066 ms |
1500 KB |
Time limit exceeded |
17 |
Runtime error |
130 ms |
848 KB |
Execution killed with signal 11 |
18 |
Execution timed out |
1042 ms |
1496 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1057 ms |
992 KB |
Time limit exceeded |
2 |
Execution timed out |
1073 ms |
992 KB |
Time limit exceeded |
3 |
Execution timed out |
1047 ms |
992 KB |
Time limit exceeded |
4 |
Runtime error |
147 ms |
852 KB |
Execution killed with signal 11 |
5 |
Execution timed out |
1034 ms |
1496 KB |
Time limit exceeded |
6 |
Runtime error |
350 ms |
1104 KB |
Execution killed with signal 11 |
7 |
Execution timed out |
1045 ms |
1496 KB |
Time limit exceeded |
8 |
Execution timed out |
1078 ms |
992 KB |
Time limit exceeded |
9 |
Execution timed out |
1067 ms |
992 KB |
Time limit exceeded |
10 |
Runtime error |
255 ms |
1112 KB |
Execution killed with signal 11 |
11 |
Runtime error |
190 ms |
852 KB |
Execution killed with signal 11 |
12 |
Runtime error |
259 ms |
884 KB |
Execution killed with signal 11 |
13 |
Execution timed out |
1090 ms |
856 KB |
Time limit exceeded |
14 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 11 |
15 |
Runtime error |
238 ms |
880 KB |
Execution killed with signal 11 |
16 |
Runtime error |
306 ms |
904 KB |
Execution killed with signal 11 |
17 |
Execution timed out |
1002 ms |
988 KB |
Time limit exceeded |
18 |
Execution timed out |
1050 ms |
992 KB |
Time limit exceeded |
19 |
Runtime error |
221 ms |
852 KB |
Execution killed with signal 11 |
20 |
Execution timed out |
1043 ms |
988 KB |
Time limit exceeded |
21 |
Runtime error |
6 ms |
604 KB |
Execution killed with signal 11 |
22 |
Execution timed out |
1085 ms |
1500 KB |
Time limit exceeded |
23 |
Execution timed out |
1044 ms |
856 KB |
Time limit exceeded |
24 |
Runtime error |
49 ms |
604 KB |
Execution killed with signal 11 |
25 |
Runtime error |
129 ms |
852 KB |
Execution killed with signal 11 |
26 |
Runtime error |
147 ms |
848 KB |
Execution killed with signal 11 |
27 |
Execution timed out |
1022 ms |
1496 KB |
Time limit exceeded |
28 |
Runtime error |
44 ms |
548 KB |
Execution killed with signal 11 |
29 |
Execution timed out |
1065 ms |
1500 KB |
Time limit exceeded |
30 |
Execution timed out |
1065 ms |
1576 KB |
Time limit exceeded |
31 |
Runtime error |
190 ms |
852 KB |
Execution killed with signal 11 |
32 |
Runtime error |
126 ms |
852 KB |
Execution killed with signal 11 |
33 |
Runtime error |
54 ms |
556 KB |
Execution killed with signal 11 |
34 |
Execution timed out |
1033 ms |
1496 KB |
Time limit exceeded |
35 |
Runtime error |
87 ms |
596 KB |
Execution killed with signal 11 |
36 |
Execution timed out |
1072 ms |
1500 KB |
Time limit exceeded |
37 |
Execution timed out |
1065 ms |
1500 KB |
Time limit exceeded |
38 |
Runtime error |
350 ms |
852 KB |
Execution killed with signal 11 |
39 |
Runtime error |
99 ms |
820 KB |
Execution killed with signal 11 |
40 |
Runtime error |
405 ms |
968 KB |
Execution killed with signal 11 |
41 |
Execution timed out |
1044 ms |
1500 KB |
Time limit exceeded |
42 |
Runtime error |
130 ms |
824 KB |
Execution killed with signal 11 |