#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
//#define int long long int
using namespace std;
int dp[10000001];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int m, q;
cin >> m >> q;
vector<int> P(m);
for(int i = 0; i < m; i++) cin >> P[i];
for(int i = 1; i <= 1e7; i++){
dp[i] = 1e9;
for(int j = m - 1; j >= 0 && j >= m - 15; j--){
dp[i] = min(dp[i], dp[i - i % P[j]] + 1);
}
}
while(q--){
int n;
cin >> n;
if(dp[n] >= 1e9) cout << "oo\n";
else cout << dp[n] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
272 ms |
39416 KB |
Output is correct |
2 |
Execution timed out |
1043 ms |
35008 KB |
Time limit exceeded |
3 |
Correct |
458 ms |
39544 KB |
Output is correct |
4 |
Execution timed out |
1088 ms |
39672 KB |
Time limit exceeded |
5 |
Correct |
857 ms |
39464 KB |
Output is correct |
6 |
Correct |
279 ms |
39500 KB |
Output is correct |
7 |
Correct |
463 ms |
39452 KB |
Output is correct |
8 |
Correct |
555 ms |
39416 KB |
Output is correct |
9 |
Correct |
892 ms |
39580 KB |
Output is correct |
10 |
Execution timed out |
1101 ms |
34424 KB |
Time limit exceeded |
11 |
Execution timed out |
1100 ms |
34252 KB |
Time limit exceeded |
12 |
Execution timed out |
1101 ms |
39036 KB |
Time limit exceeded |
13 |
Execution timed out |
1039 ms |
39616 KB |
Time limit exceeded |
14 |
Execution timed out |
1046 ms |
39596 KB |
Time limit exceeded |
15 |
Execution timed out |
1098 ms |
36540 KB |
Time limit exceeded |
16 |
Execution timed out |
1100 ms |
36580 KB |
Time limit exceeded |
17 |
Execution timed out |
1099 ms |
36856 KB |
Time limit exceeded |
18 |
Execution timed out |
1092 ms |
39540 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
870 ms |
39604 KB |
Output is correct |
2 |
Correct |
820 ms |
40568 KB |
Output is correct |
3 |
Correct |
865 ms |
40180 KB |
Output is correct |
4 |
Incorrect |
950 ms |
39800 KB |
Output isn't correct |
5 |
Correct |
848 ms |
39992 KB |
Output is correct |
6 |
Incorrect |
959 ms |
39424 KB |
Output isn't correct |
7 |
Correct |
868 ms |
39636 KB |
Output is correct |
8 |
Execution timed out |
1016 ms |
39544 KB |
Time limit exceeded |
9 |
Correct |
859 ms |
40312 KB |
Output is correct |
10 |
Correct |
869 ms |
40220 KB |
Output is correct |
11 |
Incorrect |
894 ms |
39860 KB |
Output isn't correct |
12 |
Incorrect |
972 ms |
39424 KB |
Output isn't correct |
13 |
Incorrect |
895 ms |
39540 KB |
Output isn't correct |
14 |
Incorrect |
981 ms |
39548 KB |
Output isn't correct |
15 |
Correct |
875 ms |
39888 KB |
Output is correct |
16 |
Correct |
843 ms |
40568 KB |
Output is correct |
17 |
Execution timed out |
1025 ms |
39664 KB |
Time limit exceeded |
18 |
Incorrect |
848 ms |
40696 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
908 ms |
40440 KB |
Output is correct |
2 |
Correct |
881 ms |
40312 KB |
Output is correct |
3 |
Correct |
878 ms |
40608 KB |
Output is correct |
4 |
Incorrect |
972 ms |
40568 KB |
Output isn't correct |
5 |
Correct |
847 ms |
41592 KB |
Output is correct |
6 |
Incorrect |
984 ms |
40568 KB |
Output isn't correct |
7 |
Correct |
854 ms |
41092 KB |
Output is correct |
8 |
Correct |
903 ms |
40360 KB |
Output is correct |
9 |
Correct |
944 ms |
40436 KB |
Output is correct |
10 |
Execution timed out |
1020 ms |
39668 KB |
Time limit exceeded |
11 |
Incorrect |
971 ms |
39748 KB |
Output isn't correct |
12 |
Incorrect |
992 ms |
39796 KB |
Output isn't correct |
13 |
Incorrect |
926 ms |
40952 KB |
Output isn't correct |
14 |
Execution timed out |
1068 ms |
32700 KB |
Time limit exceeded |
15 |
Execution timed out |
1000 ms |
39760 KB |
Time limit exceeded |
16 |
Incorrect |
993 ms |
39784 KB |
Output isn't correct |
17 |
Correct |
900 ms |
40056 KB |
Output is correct |
18 |
Execution timed out |
1086 ms |
40312 KB |
Time limit exceeded |
19 |
Correct |
872 ms |
39928 KB |
Output is correct |
20 |
Correct |
883 ms |
40568 KB |
Output is correct |
21 |
Execution timed out |
1098 ms |
38264 KB |
Time limit exceeded |
22 |
Correct |
930 ms |
41556 KB |
Output is correct |
23 |
Correct |
953 ms |
40864 KB |
Output is correct |
24 |
Execution timed out |
1006 ms |
40440 KB |
Time limit exceeded |
25 |
Execution timed out |
1004 ms |
40568 KB |
Time limit exceeded |
26 |
Incorrect |
977 ms |
40424 KB |
Output isn't correct |
27 |
Execution timed out |
1004 ms |
41132 KB |
Time limit exceeded |
28 |
Incorrect |
980 ms |
40568 KB |
Output isn't correct |
29 |
Correct |
886 ms |
41616 KB |
Output is correct |
30 |
Correct |
971 ms |
41432 KB |
Output is correct |
31 |
Incorrect |
936 ms |
40440 KB |
Output isn't correct |
32 |
Incorrect |
979 ms |
40572 KB |
Output isn't correct |
33 |
Incorrect |
961 ms |
40440 KB |
Output isn't correct |
34 |
Correct |
838 ms |
41080 KB |
Output is correct |
35 |
Incorrect |
962 ms |
40568 KB |
Output isn't correct |
36 |
Correct |
885 ms |
41464 KB |
Output is correct |
37 |
Correct |
883 ms |
41756 KB |
Output is correct |
38 |
Incorrect |
982 ms |
40628 KB |
Output isn't correct |
39 |
Execution timed out |
1008 ms |
40700 KB |
Time limit exceeded |
40 |
Incorrect |
950 ms |
40464 KB |
Output isn't correct |
41 |
Correct |
899 ms |
41324 KB |
Output is correct |
42 |
Execution timed out |
1087 ms |
40812 KB |
Time limit exceeded |