#include <bits/stdc++.h>
using namespace std;
#define SPEED ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define endl "\n"
#define ALL(X) X.begin(), X.end()
const int sz = 10005, inf = 1e9;
vector<int>dp(sz, inf);
void solve() {
int m, Q;
cin >> m >> Q;
vector<int> p(m);
for(int &i : p) cin >> i;
dp[0] = 0;
for(int i = 1; i <= sz; i++) {
int mini = inf;
for(int j = 0; j < m; j++) {
mini = min(mini, dp[i - (i % p[j])]);
}
dp[i] = mini + 1;
}
// for(int i = 0; i <= 10; i++) {
// cout << dp[i] << " ";
// }
// cout << endl;
while(Q--) {
int q;
cin >> q;
if(dp[q] == inf + 1) {
cout << "oo" << endl;
}
else {
cout << dp[q] << endl;
}
}
}
signed main() {
SPEED;
int tst = 1;
// cin >> tst;
for(int cs = 1; cs <= tst; cs++) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
2 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
3 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
4 |
Runtime error |
4 ms |
592 KB |
Execution killed with signal 6 |
5 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
6 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
7 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
8 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
9 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
10 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
11 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
12 |
Runtime error |
3 ms |
592 KB |
Execution killed with signal 6 |
13 |
Runtime error |
25 ms |
604 KB |
Execution killed with signal 6 |
14 |
Runtime error |
26 ms |
800 KB |
Execution killed with signal 6 |
15 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
16 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 6 |
17 |
Runtime error |
4 ms |
604 KB |
Execution killed with signal 6 |
18 |
Runtime error |
4 ms |
608 KB |
Execution killed with signal 6 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
277 ms |
892 KB |
Execution killed with signal 11 |
2 |
Execution timed out |
1072 ms |
1116 KB |
Time limit exceeded |
3 |
Execution timed out |
1057 ms |
860 KB |
Time limit exceeded |
4 |
Runtime error |
73 ms |
584 KB |
Execution killed with signal 11 |
5 |
Execution timed out |
1081 ms |
848 KB |
Time limit exceeded |
6 |
Runtime error |
29 ms |
592 KB |
Execution killed with signal 11 |
7 |
Runtime error |
276 ms |
832 KB |
Execution killed with signal 11 |
8 |
Runtime error |
24 ms |
592 KB |
Execution killed with signal 11 |
9 |
Execution timed out |
1072 ms |
848 KB |
Time limit exceeded |
10 |
Execution timed out |
1067 ms |
848 KB |
Time limit exceeded |
11 |
Runtime error |
921 ms |
1352 KB |
Execution killed with signal 11 |
12 |
Runtime error |
50 ms |
552 KB |
Execution killed with signal 11 |
13 |
Runtime error |
69 ms |
544 KB |
Execution killed with signal 11 |
14 |
Runtime error |
73 ms |
560 KB |
Execution killed with signal 11 |
15 |
Runtime error |
962 ms |
1368 KB |
Execution killed with signal 11 |
16 |
Execution timed out |
1065 ms |
1104 KB |
Time limit exceeded |
17 |
Runtime error |
71 ms |
584 KB |
Execution killed with signal 11 |
18 |
Execution timed out |
1072 ms |
1104 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
848 KB |
Time limit exceeded |
2 |
Execution timed out |
1067 ms |
848 KB |
Time limit exceeded |
3 |
Execution timed out |
1075 ms |
848 KB |
Time limit exceeded |
4 |
Runtime error |
79 ms |
588 KB |
Execution killed with signal 11 |
5 |
Execution timed out |
1059 ms |
1104 KB |
Time limit exceeded |
6 |
Runtime error |
187 ms |
836 KB |
Execution killed with signal 11 |
7 |
Execution timed out |
1065 ms |
1104 KB |
Time limit exceeded |
8 |
Execution timed out |
1063 ms |
848 KB |
Time limit exceeded |
9 |
Execution timed out |
1059 ms |
848 KB |
Time limit exceeded |
10 |
Runtime error |
137 ms |
828 KB |
Execution killed with signal 11 |
11 |
Runtime error |
102 ms |
588 KB |
Execution killed with signal 11 |
12 |
Runtime error |
137 ms |
832 KB |
Execution killed with signal 11 |
13 |
Runtime error |
690 ms |
1016 KB |
Execution killed with signal 11 |
14 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 11 |
15 |
Runtime error |
128 ms |
828 KB |
Execution killed with signal 11 |
16 |
Runtime error |
164 ms |
844 KB |
Execution killed with signal 11 |
17 |
Execution timed out |
1035 ms |
1352 KB |
Time limit exceeded |
18 |
Execution timed out |
1057 ms |
848 KB |
Time limit exceeded |
19 |
Runtime error |
122 ms |
828 KB |
Execution killed with signal 11 |
20 |
Execution timed out |
1062 ms |
848 KB |
Time limit exceeded |
21 |
Runtime error |
4 ms |
592 KB |
Execution killed with signal 11 |
22 |
Execution timed out |
1089 ms |
1104 KB |
Time limit exceeded |
23 |
Runtime error |
692 ms |
1020 KB |
Execution killed with signal 11 |
24 |
Runtime error |
27 ms |
584 KB |
Execution killed with signal 11 |
25 |
Runtime error |
69 ms |
804 KB |
Execution killed with signal 11 |
26 |
Runtime error |
80 ms |
552 KB |
Execution killed with signal 11 |
27 |
Execution timed out |
1059 ms |
1272 KB |
Time limit exceeded |
28 |
Runtime error |
25 ms |
592 KB |
Execution killed with signal 11 |
29 |
Execution timed out |
1073 ms |
1104 KB |
Time limit exceeded |
30 |
Execution timed out |
1051 ms |
860 KB |
Time limit exceeded |
31 |
Runtime error |
102 ms |
584 KB |
Execution killed with signal 11 |
32 |
Runtime error |
69 ms |
584 KB |
Execution killed with signal 11 |
33 |
Runtime error |
30 ms |
544 KB |
Execution killed with signal 11 |
34 |
Execution timed out |
1061 ms |
1104 KB |
Time limit exceeded |
35 |
Runtime error |
48 ms |
584 KB |
Execution killed with signal 11 |
36 |
Execution timed out |
1073 ms |
1272 KB |
Time limit exceeded |
37 |
Execution timed out |
1059 ms |
1104 KB |
Time limit exceeded |
38 |
Runtime error |
188 ms |
836 KB |
Execution killed with signal 11 |
39 |
Runtime error |
54 ms |
552 KB |
Execution killed with signal 11 |
40 |
Runtime error |
217 ms |
856 KB |
Execution killed with signal 11 |
41 |
Execution timed out |
1053 ms |
1104 KB |
Time limit exceeded |
42 |
Runtime error |
70 ms |
584 KB |
Execution killed with signal 11 |