#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int n, q;
int p[100009];
int ans[10000001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
srand(time(NULL));
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
cin >> n >> q;
for(int i = 0; i < n; ++i)
cin >> p[i];
reverse(p, p+n);
ans[0] = 0;
int lim = 1e7+1;
for(int i = 1; i < lim; ++i){
int goback = -1;
for(int j = 0; j < min(n, 5); ++j)
goback = max(goback, i%p[j]);
int cnt = 10;
while(cnt--){
int j = rand()%n;
goback = max(goback, i%p[j]);
}
if(goback == 0){
lim = i;
break;
}
ans[i] = 1+ans[i-goback];
}
while(q--){
int x;
cin >> x;
if(x >= lim)
cout << "oo\n";
else
cout << ans[x] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Execution timed out |
1075 ms |
18880 KB |
Time limit exceeded |
3 |
Correct |
62 ms |
1400 KB |
Output is correct |
4 |
Execution timed out |
1091 ms |
20088 KB |
Time limit exceeded |
5 |
Execution timed out |
1094 ms |
18408 KB |
Time limit exceeded |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
61 ms |
1404 KB |
Output is correct |
8 |
Correct |
212 ms |
3964 KB |
Output is correct |
9 |
Execution timed out |
1089 ms |
18296 KB |
Time limit exceeded |
10 |
Execution timed out |
1090 ms |
18356 KB |
Time limit exceeded |
11 |
Execution timed out |
1073 ms |
18424 KB |
Time limit exceeded |
12 |
Execution timed out |
1088 ms |
19984 KB |
Time limit exceeded |
13 |
Execution timed out |
1085 ms |
20540 KB |
Time limit exceeded |
14 |
Execution timed out |
1087 ms |
21004 KB |
Time limit exceeded |
15 |
Execution timed out |
1092 ms |
19216 KB |
Time limit exceeded |
16 |
Execution timed out |
1095 ms |
19336 KB |
Time limit exceeded |
17 |
Execution timed out |
1087 ms |
19244 KB |
Time limit exceeded |
18 |
Execution timed out |
1080 ms |
19820 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
21536 KB |
Time limit exceeded |
2 |
Execution timed out |
1081 ms |
20472 KB |
Time limit exceeded |
3 |
Execution timed out |
1090 ms |
20092 KB |
Time limit exceeded |
4 |
Execution timed out |
1087 ms |
22220 KB |
Time limit exceeded |
5 |
Execution timed out |
1095 ms |
19748 KB |
Time limit exceeded |
6 |
Execution timed out |
1037 ms |
21432 KB |
Time limit exceeded |
7 |
Execution timed out |
1097 ms |
21156 KB |
Time limit exceeded |
8 |
Execution timed out |
1082 ms |
20616 KB |
Time limit exceeded |
9 |
Execution timed out |
1099 ms |
20088 KB |
Time limit exceeded |
10 |
Execution timed out |
1085 ms |
19220 KB |
Time limit exceeded |
11 |
Execution timed out |
1065 ms |
20048 KB |
Time limit exceeded |
12 |
Execution timed out |
1085 ms |
21772 KB |
Time limit exceeded |
13 |
Execution timed out |
1087 ms |
22484 KB |
Time limit exceeded |
14 |
Execution timed out |
1092 ms |
21872 KB |
Time limit exceeded |
15 |
Execution timed out |
1027 ms |
17704 KB |
Time limit exceeded |
16 |
Execution timed out |
1087 ms |
20220 KB |
Time limit exceeded |
17 |
Execution timed out |
1052 ms |
21440 KB |
Time limit exceeded |
18 |
Execution timed out |
1089 ms |
18296 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
19388 KB |
Time limit exceeded |
2 |
Execution timed out |
1094 ms |
19812 KB |
Time limit exceeded |
3 |
Execution timed out |
1086 ms |
18768 KB |
Time limit exceeded |
4 |
Execution timed out |
1092 ms |
21356 KB |
Time limit exceeded |
5 |
Execution timed out |
1051 ms |
18552 KB |
Time limit exceeded |
6 |
Execution timed out |
1098 ms |
20528 KB |
Time limit exceeded |
7 |
Execution timed out |
1095 ms |
18680 KB |
Time limit exceeded |
8 |
Execution timed out |
1087 ms |
20036 KB |
Time limit exceeded |
9 |
Execution timed out |
1082 ms |
19352 KB |
Time limit exceeded |
10 |
Execution timed out |
1098 ms |
20868 KB |
Time limit exceeded |
11 |
Execution timed out |
1097 ms |
21240 KB |
Time limit exceeded |
12 |
Execution timed out |
1090 ms |
20944 KB |
Time limit exceeded |
13 |
Execution timed out |
1095 ms |
19356 KB |
Time limit exceeded |
14 |
Execution timed out |
1088 ms |
18772 KB |
Time limit exceeded |
15 |
Execution timed out |
1064 ms |
18668 KB |
Time limit exceeded |
16 |
Execution timed out |
1082 ms |
20440 KB |
Time limit exceeded |
17 |
Execution timed out |
1091 ms |
19720 KB |
Time limit exceeded |
18 |
Execution timed out |
1083 ms |
19404 KB |
Time limit exceeded |
19 |
Execution timed out |
1058 ms |
19748 KB |
Time limit exceeded |
20 |
Execution timed out |
1098 ms |
19960 KB |
Time limit exceeded |
21 |
Execution timed out |
1093 ms |
19704 KB |
Time limit exceeded |
22 |
Execution timed out |
1072 ms |
15336 KB |
Time limit exceeded |
23 |
Execution timed out |
1067 ms |
16700 KB |
Time limit exceeded |
24 |
Execution timed out |
1052 ms |
18808 KB |
Time limit exceeded |
25 |
Execution timed out |
1093 ms |
22292 KB |
Time limit exceeded |
26 |
Execution timed out |
1065 ms |
20748 KB |
Time limit exceeded |
27 |
Execution timed out |
1098 ms |
19204 KB |
Time limit exceeded |
28 |
Execution timed out |
1082 ms |
22392 KB |
Time limit exceeded |
29 |
Execution timed out |
1101 ms |
19448 KB |
Time limit exceeded |
30 |
Execution timed out |
1088 ms |
18040 KB |
Time limit exceeded |
31 |
Execution timed out |
1089 ms |
19416 KB |
Time limit exceeded |
32 |
Execution timed out |
1089 ms |
18044 KB |
Time limit exceeded |
33 |
Execution timed out |
1098 ms |
22832 KB |
Time limit exceeded |
34 |
Execution timed out |
1098 ms |
17512 KB |
Time limit exceeded |
35 |
Execution timed out |
1087 ms |
21032 KB |
Time limit exceeded |
36 |
Execution timed out |
1096 ms |
18680 KB |
Time limit exceeded |
37 |
Execution timed out |
1082 ms |
18732 KB |
Time limit exceeded |
38 |
Execution timed out |
1101 ms |
21368 KB |
Time limit exceeded |
39 |
Execution timed out |
1086 ms |
22500 KB |
Time limit exceeded |
40 |
Execution timed out |
1101 ms |
21624 KB |
Time limit exceeded |
41 |
Execution timed out |
1088 ms |
19964 KB |
Time limit exceeded |
42 |
Execution timed out |
1090 ms |
21252 KB |
Time limit exceeded |