//ngqminh.cl2735
/*
🛸 🌎 ° 🌓 • .°• 🚀 ✯
★ * ° 🛰 °· 🪐
. • ° ★ • ☄
______________________________________________________
myv myv myv myv myv
BUH BUH LMAO
*/
#include <bits/stdc++.h>
#define PB push_back
#define Random(lf, rt) (lf + rand() % (rt - lf + 1))
#define pii pair <int,int>
#define vi vector <int>
#define vii vector <pii>
#define mpa make_pair
#define oo 1e9 + 5
#define F first
#define S second
#define reset(x, i) memset(x,i,sizeof(x))
#define sz(x) int(x.size())
#define maxn 100005
#define maxx 10000007
#define MOD
#define all(x) x.begin(), x.end()
#define cosdo(x) cos((x)/180 * Pi)
#define sindo(x) sin((x)/180 * Pi)
#define tando(x) tan((x)/180 * Pi)
#define cotdo(x) 1/tando(x)
#define Task "BirthDay"
using namespace std;
const double Pi = acos(-1);
typedef long long ll;
typedef long double ld;
int dp[maxx], a[maxn];
int n[maxn];
int m, q;
int main() {
ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
// freopen(Task".inp", "r", stdin);
// freopen(Task".out", "w", stdout);
cin >> m >> q;
for (int i = 1; i <= m; i ++)
cin >> a[i];
for (int i = 1; i <= q; i ++)
cin >> n[i];
sort(a + 1, a + m + 1);
int mx = *max_element(n + 1, n + q + 1);
for (int x = 1; x <= mx; x ++) dp[x] = oo;
dp[0] = 0;
for (int x = 1; x < a[m]; x ++) dp[x] = 1;
for (int x = a[m]; x <= mx; x ++)
{
for (int i = 1; i <= m; i ++) if(x % a[i])
dp[x] = min(dp[x], dp[x - x % a[i]] + 1);
}
for (int i = 1; i <= q; i ++){
if(dp[n[i]] >= oo) cout << "oo\n";
else cout << dp[n[i]] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
472 KB |
Output is correct |
2 |
Correct |
3 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
4 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
2 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
6 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
464 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
464 KB |
Output is correct |
18 |
Correct |
4 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
39076 KB |
Time limit exceeded |
2 |
Correct |
31 ms |
36552 KB |
Output is correct |
3 |
Execution timed out |
1091 ms |
19488 KB |
Time limit exceeded |
4 |
Execution timed out |
1095 ms |
35664 KB |
Time limit exceeded |
5 |
Execution timed out |
1099 ms |
10960 KB |
Time limit exceeded |
6 |
Execution timed out |
1049 ms |
13904 KB |
Time limit exceeded |
7 |
Execution timed out |
1096 ms |
39096 KB |
Time limit exceeded |
8 |
Execution timed out |
1085 ms |
14928 KB |
Time limit exceeded |
9 |
Execution timed out |
1087 ms |
11216 KB |
Time limit exceeded |
10 |
Execution timed out |
1082 ms |
19408 KB |
Time limit exceeded |
11 |
Execution timed out |
1088 ms |
39880 KB |
Time limit exceeded |
12 |
Execution timed out |
1093 ms |
33744 KB |
Time limit exceeded |
13 |
Execution timed out |
1096 ms |
39120 KB |
Time limit exceeded |
14 |
Execution timed out |
1055 ms |
35664 KB |
Time limit exceeded |
15 |
Execution timed out |
1086 ms |
13264 KB |
Time limit exceeded |
16 |
Correct |
36 ms |
36560 KB |
Output is correct |
17 |
Execution timed out |
1099 ms |
38992 KB |
Time limit exceeded |
18 |
Execution timed out |
1100 ms |
40520 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1087 ms |
40392 KB |
Time limit exceeded |
2 |
Execution timed out |
1091 ms |
40272 KB |
Time limit exceeded |
3 |
Execution timed out |
1090 ms |
29012 KB |
Time limit exceeded |
4 |
Execution timed out |
1096 ms |
40400 KB |
Time limit exceeded |
5 |
Execution timed out |
1085 ms |
41680 KB |
Time limit exceeded |
6 |
Execution timed out |
1089 ms |
40524 KB |
Time limit exceeded |
7 |
Execution timed out |
1095 ms |
29676 KB |
Time limit exceeded |
8 |
Execution timed out |
1093 ms |
40392 KB |
Time limit exceeded |
9 |
Execution timed out |
1088 ms |
40400 KB |
Time limit exceeded |
10 |
Execution timed out |
1099 ms |
39632 KB |
Time limit exceeded |
11 |
Execution timed out |
1037 ms |
39628 KB |
Time limit exceeded |
12 |
Execution timed out |
1096 ms |
39624 KB |
Time limit exceeded |
13 |
Execution timed out |
1095 ms |
21576 KB |
Time limit exceeded |
14 |
Execution timed out |
1095 ms |
25168 KB |
Time limit exceeded |
15 |
Execution timed out |
1097 ms |
39760 KB |
Time limit exceeded |
16 |
Execution timed out |
1097 ms |
39680 KB |
Time limit exceeded |
17 |
Execution timed out |
1099 ms |
40016 KB |
Time limit exceeded |
18 |
Execution timed out |
1088 ms |
40272 KB |
Time limit exceeded |
19 |
Execution timed out |
1094 ms |
39760 KB |
Time limit exceeded |
20 |
Execution timed out |
1089 ms |
29056 KB |
Time limit exceeded |
21 |
Execution timed out |
1101 ms |
40528 KB |
Time limit exceeded |
22 |
Execution timed out |
1088 ms |
41672 KB |
Time limit exceeded |
23 |
Execution timed out |
1089 ms |
40904 KB |
Time limit exceeded |
24 |
Execution timed out |
1094 ms |
40520 KB |
Time limit exceeded |
25 |
Execution timed out |
1088 ms |
40528 KB |
Time limit exceeded |
26 |
Execution timed out |
1092 ms |
40404 KB |
Time limit exceeded |
27 |
Execution timed out |
1072 ms |
29620 KB |
Time limit exceeded |
28 |
Execution timed out |
1087 ms |
40528 KB |
Time limit exceeded |
29 |
Execution timed out |
1083 ms |
41652 KB |
Time limit exceeded |
30 |
Execution timed out |
1060 ms |
41288 KB |
Time limit exceeded |
31 |
Execution timed out |
1100 ms |
40376 KB |
Time limit exceeded |
32 |
Execution timed out |
1088 ms |
40528 KB |
Time limit exceeded |
33 |
Execution timed out |
1057 ms |
40400 KB |
Time limit exceeded |
34 |
Execution timed out |
1084 ms |
29716 KB |
Time limit exceeded |
35 |
Execution timed out |
1094 ms |
40512 KB |
Time limit exceeded |
36 |
Execution timed out |
1052 ms |
41556 KB |
Time limit exceeded |
37 |
Execution timed out |
1096 ms |
41656 KB |
Time limit exceeded |
38 |
Execution timed out |
1098 ms |
40528 KB |
Time limit exceeded |
39 |
Execution timed out |
1086 ms |
40516 KB |
Time limit exceeded |
40 |
Execution timed out |
1093 ms |
40552 KB |
Time limit exceeded |
41 |
Correct |
34 ms |
30920 KB |
Output is correct |
42 |
Execution timed out |
1087 ms |
40656 KB |
Time limit exceeded |