#include <bits/stdc++.h>
#define N 100050
using namespace std;
int n, q, p[N], dp[10000005], prox[10000005], pr[N], lim;
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>q;
for(int i = 1; i <= n; i++)
{
cin>>p[i];
for(int j = p[i]; j < 10000005; j+= p[i]) pr[j] = p[i];
}
pr[0] = p[n];
dp[0] = 1;
for(int i = 0; i < 10000005; i++)
{
if(!dp[i]) continue;
for(int j = lim + 1; j < min(10000005, i + pr[i]); j++) dp[j] = dp[i] + 1;
lim = min(10000005, i + pr[i]) - 1;
}
for(int i = 1, x; i <= q; i++)
{
cin>>x;
if(!dp[x]) cout<<"oo\n";
else cout<<dp[x] - 1<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
64 ms |
39544 KB |
Output isn't correct |
2 |
Incorrect |
438 ms |
78712 KB |
Output isn't correct |
3 |
Incorrect |
79 ms |
78712 KB |
Output isn't correct |
4 |
Incorrect |
596 ms |
78912 KB |
Output isn't correct |
5 |
Incorrect |
243 ms |
78912 KB |
Output isn't correct |
6 |
Incorrect |
58 ms |
78912 KB |
Output isn't correct |
7 |
Incorrect |
74 ms |
78912 KB |
Output isn't correct |
8 |
Incorrect |
88 ms |
78912 KB |
Output isn't correct |
9 |
Incorrect |
275 ms |
79036 KB |
Output isn't correct |
10 |
Incorrect |
320 ms |
79036 KB |
Output isn't correct |
11 |
Incorrect |
325 ms |
79036 KB |
Output isn't correct |
12 |
Incorrect |
700 ms |
79036 KB |
Output isn't correct |
13 |
Execution timed out |
1081 ms |
79036 KB |
Time limit exceeded |
14 |
Execution timed out |
1094 ms |
79036 KB |
Time limit exceeded |
15 |
Incorrect |
396 ms |
79036 KB |
Output isn't correct |
16 |
Incorrect |
401 ms |
79036 KB |
Output isn't correct |
17 |
Incorrect |
483 ms |
79068 KB |
Output isn't correct |
18 |
Incorrect |
601 ms |
79068 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1073 ms |
79068 KB |
Time limit exceeded |
2 |
Execution timed out |
1091 ms |
79068 KB |
Time limit exceeded |
3 |
Execution timed out |
1091 ms |
79068 KB |
Time limit exceeded |
4 |
Execution timed out |
1087 ms |
79068 KB |
Time limit exceeded |
5 |
Execution timed out |
1088 ms |
79068 KB |
Time limit exceeded |
6 |
Execution timed out |
1084 ms |
79068 KB |
Time limit exceeded |
7 |
Execution timed out |
1086 ms |
79068 KB |
Time limit exceeded |
8 |
Execution timed out |
1084 ms |
79068 KB |
Time limit exceeded |
9 |
Execution timed out |
1085 ms |
79068 KB |
Time limit exceeded |
10 |
Execution timed out |
1089 ms |
79068 KB |
Time limit exceeded |
11 |
Execution timed out |
1088 ms |
79068 KB |
Time limit exceeded |
12 |
Execution timed out |
1081 ms |
79068 KB |
Time limit exceeded |
13 |
Execution timed out |
1068 ms |
79068 KB |
Time limit exceeded |
14 |
Execution timed out |
1080 ms |
79068 KB |
Time limit exceeded |
15 |
Execution timed out |
1082 ms |
79068 KB |
Time limit exceeded |
16 |
Execution timed out |
1082 ms |
79068 KB |
Time limit exceeded |
17 |
Execution timed out |
1086 ms |
79068 KB |
Time limit exceeded |
18 |
Execution timed out |
1085 ms |
79068 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1074 ms |
79068 KB |
Time limit exceeded |
2 |
Execution timed out |
1089 ms |
79068 KB |
Time limit exceeded |
3 |
Execution timed out |
1090 ms |
79068 KB |
Time limit exceeded |
4 |
Execution timed out |
1096 ms |
79068 KB |
Time limit exceeded |
5 |
Execution timed out |
1068 ms |
79068 KB |
Time limit exceeded |
6 |
Execution timed out |
1080 ms |
79068 KB |
Time limit exceeded |
7 |
Execution timed out |
1083 ms |
79068 KB |
Time limit exceeded |
8 |
Execution timed out |
1084 ms |
79068 KB |
Time limit exceeded |
9 |
Execution timed out |
1079 ms |
79068 KB |
Time limit exceeded |
10 |
Execution timed out |
1087 ms |
79068 KB |
Time limit exceeded |
11 |
Execution timed out |
1087 ms |
79068 KB |
Time limit exceeded |
12 |
Execution timed out |
1085 ms |
79068 KB |
Time limit exceeded |
13 |
Execution timed out |
1092 ms |
79068 KB |
Time limit exceeded |
14 |
Incorrect |
408 ms |
79760 KB |
Output isn't correct |
15 |
Execution timed out |
1074 ms |
79760 KB |
Time limit exceeded |
16 |
Execution timed out |
1085 ms |
79760 KB |
Time limit exceeded |
17 |
Execution timed out |
1084 ms |
79760 KB |
Time limit exceeded |
18 |
Execution timed out |
1065 ms |
79760 KB |
Time limit exceeded |
19 |
Execution timed out |
1067 ms |
79760 KB |
Time limit exceeded |
20 |
Execution timed out |
1070 ms |
79760 KB |
Time limit exceeded |
21 |
Incorrect |
789 ms |
79760 KB |
Output isn't correct |
22 |
Execution timed out |
1070 ms |
79760 KB |
Time limit exceeded |
23 |
Execution timed out |
1075 ms |
79760 KB |
Time limit exceeded |
24 |
Execution timed out |
1055 ms |
79760 KB |
Time limit exceeded |
25 |
Execution timed out |
1090 ms |
79760 KB |
Time limit exceeded |
26 |
Execution timed out |
1078 ms |
79760 KB |
Time limit exceeded |
27 |
Execution timed out |
1066 ms |
79760 KB |
Time limit exceeded |
28 |
Execution timed out |
1076 ms |
79760 KB |
Time limit exceeded |
29 |
Execution timed out |
1071 ms |
79760 KB |
Time limit exceeded |
30 |
Execution timed out |
1073 ms |
79760 KB |
Time limit exceeded |
31 |
Execution timed out |
1089 ms |
79760 KB |
Time limit exceeded |
32 |
Execution timed out |
1067 ms |
79760 KB |
Time limit exceeded |
33 |
Execution timed out |
1082 ms |
79760 KB |
Time limit exceeded |
34 |
Execution timed out |
1085 ms |
79760 KB |
Time limit exceeded |
35 |
Execution timed out |
1090 ms |
79760 KB |
Time limit exceeded |
36 |
Execution timed out |
1085 ms |
79760 KB |
Time limit exceeded |
37 |
Execution timed out |
1085 ms |
79760 KB |
Time limit exceeded |
38 |
Execution timed out |
1063 ms |
79760 KB |
Time limit exceeded |
39 |
Execution timed out |
1082 ms |
79760 KB |
Time limit exceeded |
40 |
Execution timed out |
1076 ms |
79760 KB |
Time limit exceeded |
41 |
Execution timed out |
1088 ms |
79760 KB |
Time limit exceeded |
42 |
Execution timed out |
1075 ms |
79760 KB |
Time limit exceeded |