#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);
int f(vector<int> &a, int w) {
int t = 0;
for(int i = 0; i < (int)a.size(); i++) {
t = max(t, (w % a[i]));
}
if(t == 0) t = -1;
return t;
}
void solve() {
int m, q;
cin >> m >> q;
vector<int> a(m);
for(int i = 0; i < m; i++) cin >> a[i];
int ans = 0;
while(q--) {
int qq;
cin >> qq;
bool cock = false;
while(qq > 0) {
int tmp = f(a, qq);
if(tmp == -1) {
cock = true;
break;
}
qq -= tmp;
ans++;
}
if(cock) {
cout << "oo" << endl;
} else {
cout << ans << endl;
}
}
}
signed main() {
SPEED;
int tst = 1;
// cin >> tst;
while(tst--) {
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
336 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
592 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
6 |
Incorrect |
3 ms |
336 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
508 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
10 |
Incorrect |
3 ms |
336 KB |
Output isn't correct |
11 |
Incorrect |
5 ms |
336 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
13 |
Incorrect |
4 ms |
336 KB |
Output isn't correct |
14 |
Incorrect |
22 ms |
336 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
17 |
Incorrect |
15 ms |
596 KB |
Output isn't correct |
18 |
Incorrect |
5 ms |
592 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
592 KB |
Output is correct |
2 |
Correct |
7 ms |
1252 KB |
Output is correct |
3 |
Correct |
5 ms |
1104 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
4 ms |
848 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
592 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
5 ms |
848 KB |
Output is correct |
10 |
Correct |
5 ms |
1016 KB |
Output is correct |
11 |
Correct |
5 ms |
848 KB |
Output is correct |
12 |
Correct |
2 ms |
592 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
4 ms |
848 KB |
Output is correct |
16 |
Correct |
7 ms |
1104 KB |
Output is correct |
17 |
Correct |
3 ms |
336 KB |
Output is correct |
18 |
Correct |
8 ms |
1104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1053 ms |
928 KB |
Time limit exceeded |
2 |
Execution timed out |
1063 ms |
948 KB |
Time limit exceeded |
3 |
Execution timed out |
1034 ms |
924 KB |
Time limit exceeded |
4 |
Execution timed out |
1059 ms |
808 KB |
Time limit exceeded |
5 |
Execution timed out |
1067 ms |
1304 KB |
Time limit exceeded |
6 |
Execution timed out |
1049 ms |
760 KB |
Time limit exceeded |
7 |
Execution timed out |
1060 ms |
1104 KB |
Time limit exceeded |
8 |
Execution timed out |
1061 ms |
1292 KB |
Time limit exceeded |
9 |
Execution timed out |
1055 ms |
848 KB |
Time limit exceeded |
10 |
Execution timed out |
1048 ms |
588 KB |
Time limit exceeded |
11 |
Execution timed out |
1062 ms |
336 KB |
Time limit exceeded |
12 |
Execution timed out |
1060 ms |
584 KB |
Time limit exceeded |
13 |
Execution timed out |
1060 ms |
760 KB |
Time limit exceeded |
14 |
Execution timed out |
1062 ms |
336 KB |
Time limit exceeded |
15 |
Execution timed out |
1059 ms |
584 KB |
Time limit exceeded |
16 |
Execution timed out |
1070 ms |
576 KB |
Time limit exceeded |
17 |
Execution timed out |
1066 ms |
848 KB |
Time limit exceeded |
18 |
Execution timed out |
1050 ms |
940 KB |
Time limit exceeded |
19 |
Execution timed out |
1067 ms |
584 KB |
Time limit exceeded |
20 |
Execution timed out |
1061 ms |
848 KB |
Time limit exceeded |
21 |
Execution timed out |
1071 ms |
336 KB |
Time limit exceeded |
22 |
Execution timed out |
1067 ms |
1104 KB |
Time limit exceeded |
23 |
Execution timed out |
1072 ms |
760 KB |
Time limit exceeded |
24 |
Execution timed out |
1046 ms |
556 KB |
Time limit exceeded |
25 |
Execution timed out |
1065 ms |
336 KB |
Time limit exceeded |
26 |
Execution timed out |
1065 ms |
584 KB |
Time limit exceeded |
27 |
Execution timed out |
1066 ms |
1104 KB |
Time limit exceeded |
28 |
Execution timed out |
1053 ms |
536 KB |
Time limit exceeded |
29 |
Execution timed out |
1067 ms |
1104 KB |
Time limit exceeded |
30 |
Execution timed out |
1076 ms |
1076 KB |
Time limit exceeded |
31 |
Execution timed out |
1060 ms |
584 KB |
Time limit exceeded |
32 |
Execution timed out |
1062 ms |
548 KB |
Time limit exceeded |
33 |
Execution timed out |
1063 ms |
568 KB |
Time limit exceeded |
34 |
Execution timed out |
1045 ms |
1320 KB |
Time limit exceeded |
35 |
Execution timed out |
1068 ms |
560 KB |
Time limit exceeded |
36 |
Execution timed out |
1051 ms |
1236 KB |
Time limit exceeded |
37 |
Execution timed out |
1074 ms |
1308 KB |
Time limit exceeded |
38 |
Execution timed out |
1049 ms |
764 KB |
Time limit exceeded |
39 |
Execution timed out |
1068 ms |
540 KB |
Time limit exceeded |
40 |
Execution timed out |
1047 ms |
848 KB |
Time limit exceeded |
41 |
Execution timed out |
1065 ms |
1624 KB |
Time limit exceeded |
42 |
Execution timed out |
1066 ms |
336 KB |
Time limit exceeded |