#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 = 0; i < m; i++) cin >> p[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();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
592 KB |
Execution killed with signal 6 |
2 |
Runtime error |
3 ms |
592 KB |
Execution killed with signal 6 |
3 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
4 |
Runtime error |
17 ms |
592 KB |
Execution killed with signal 6 |
5 |
Runtime error |
2 ms |
760 KB |
Execution killed with signal 6 |
6 |
Runtime error |
3 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 |
3 ms |
756 KB |
Execution killed with signal 6 |
11 |
Runtime error |
4 ms |
592 KB |
Execution killed with signal 6 |
12 |
Runtime error |
4 ms |
592 KB |
Execution killed with signal 6 |
13 |
Runtime error |
27 ms |
812 KB |
Execution killed with signal 6 |
14 |
Runtime error |
38 ms |
584 KB |
Execution killed with signal 6 |
15 |
Runtime error |
3 ms |
592 KB |
Execution killed with signal 6 |
16 |
Runtime error |
3 ms |
592 KB |
Execution killed with signal 6 |
17 |
Runtime error |
18 ms |
592 KB |
Execution killed with signal 6 |
18 |
Runtime error |
17 ms |
592 KB |
Execution killed with signal 6 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
278 ms |
840 KB |
Execution killed with signal 11 |
2 |
Execution timed out |
1057 ms |
1104 KB |
Time limit exceeded |
3 |
Execution timed out |
1075 ms |
848 KB |
Time limit exceeded |
4 |
Runtime error |
73 ms |
584 KB |
Execution killed with signal 11 |
5 |
Execution timed out |
1074 ms |
848 KB |
Time limit exceeded |
6 |
Runtime error |
30 ms |
592 KB |
Execution killed with signal 11 |
7 |
Runtime error |
277 ms |
884 KB |
Execution killed with signal 11 |
8 |
Runtime error |
24 ms |
592 KB |
Execution killed with signal 11 |
9 |
Execution timed out |
1048 ms |
848 KB |
Time limit exceeded |
10 |
Execution timed out |
1036 ms |
848 KB |
Time limit exceeded |
11 |
Runtime error |
937 ms |
1364 KB |
Execution killed with signal 11 |
12 |
Runtime error |
52 ms |
584 KB |
Execution killed with signal 11 |
13 |
Runtime error |
69 ms |
584 KB |
Execution killed with signal 11 |
14 |
Runtime error |
73 ms |
584 KB |
Execution killed with signal 11 |
15 |
Runtime error |
984 ms |
1384 KB |
Execution killed with signal 11 |
16 |
Execution timed out |
1063 ms |
1104 KB |
Time limit exceeded |
17 |
Runtime error |
71 ms |
584 KB |
Execution killed with signal 11 |
18 |
Execution timed out |
1061 ms |
1276 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1043 ms |
848 KB |
Time limit exceeded |
2 |
Execution timed out |
1054 ms |
848 KB |
Time limit exceeded |
3 |
Execution timed out |
1064 ms |
848 KB |
Time limit exceeded |
4 |
Runtime error |
80 ms |
584 KB |
Execution killed with signal 11 |
5 |
Execution timed out |
1063 ms |
1104 KB |
Time limit exceeded |
6 |
Runtime error |
190 ms |
848 KB |
Execution killed with signal 11 |
7 |
Execution timed out |
1071 ms |
1276 KB |
Time limit exceeded |
8 |
Execution timed out |
1045 ms |
848 KB |
Time limit exceeded |
9 |
Execution timed out |
1046 ms |
848 KB |
Time limit exceeded |
10 |
Runtime error |
137 ms |
840 KB |
Execution killed with signal 11 |
11 |
Runtime error |
103 ms |
824 KB |
Execution killed with signal 11 |
12 |
Runtime error |
137 ms |
832 KB |
Execution killed with signal 11 |
13 |
Runtime error |
695 ms |
1020 KB |
Execution killed with signal 11 |
14 |
Runtime error |
3 ms |
592 KB |
Execution killed with signal 11 |
15 |
Runtime error |
128 ms |
820 KB |
Execution killed with signal 11 |
16 |
Runtime error |
168 ms |
840 KB |
Execution killed with signal 11 |
17 |
Execution timed out |
1046 ms |
1352 KB |
Time limit exceeded |
18 |
Execution timed out |
1061 ms |
848 KB |
Time limit exceeded |
19 |
Runtime error |
120 ms |
584 KB |
Execution killed with signal 11 |
20 |
Execution timed out |
1072 ms |
848 KB |
Time limit exceeded |
21 |
Runtime error |
4 ms |
592 KB |
Execution killed with signal 11 |
22 |
Execution timed out |
1093 ms |
1104 KB |
Time limit exceeded |
23 |
Runtime error |
689 ms |
1096 KB |
Execution killed with signal 11 |
24 |
Runtime error |
27 ms |
592 KB |
Execution killed with signal 11 |
25 |
Runtime error |
69 ms |
556 KB |
Execution killed with signal 11 |
26 |
Runtime error |
79 ms |
584 KB |
Execution killed with signal 11 |
27 |
Execution timed out |
1066 ms |
1104 KB |
Time limit exceeded |
28 |
Runtime error |
24 ms |
592 KB |
Execution killed with signal 11 |
29 |
Execution timed out |
1074 ms |
1104 KB |
Time limit exceeded |
30 |
Execution timed out |
1065 ms |
848 KB |
Time limit exceeded |
31 |
Runtime error |
103 ms |
820 KB |
Execution killed with signal 11 |
32 |
Runtime error |
68 ms |
552 KB |
Execution killed with signal 11 |
33 |
Runtime error |
31 ms |
584 KB |
Execution killed with signal 11 |
34 |
Execution timed out |
1046 ms |
1104 KB |
Time limit exceeded |
35 |
Runtime error |
48 ms |
544 KB |
Execution killed with signal 11 |
36 |
Execution timed out |
1073 ms |
1104 KB |
Time limit exceeded |
37 |
Execution timed out |
1037 ms |
1104 KB |
Time limit exceeded |
38 |
Runtime error |
189 ms |
836 KB |
Execution killed with signal 11 |
39 |
Runtime error |
54 ms |
584 KB |
Execution killed with signal 11 |
40 |
Runtime error |
218 ms |
840 KB |
Execution killed with signal 11 |
41 |
Execution timed out |
1060 ms |
1104 KB |
Time limit exceeded |
42 |
Runtime error |
70 ms |
584 KB |
Execution killed with signal 11 |