#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { out << x.first << " " << x.second; return out;}
template<class T, class T2> inline istream &operator >>(istream &in, pair<T, T2> &x) { in >> x.first >> x.second; return in;}
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
#define debug(...) cout << "Line: " << __LINE__ << endl; \
printDebug(", "#__VA_ARGS__, __VA_ARGS__)
template <typename T>
void printDebug(const char* name, T&& arg1) { cout << (name + 2) << " = " << arg1 << endl; }
template <typename T, typename... T2>
void printDebug(const char* names, T&& arg1, T2&&... args) {
const char* end = strchr(names + 1, ',');
cout.write(names + 2, end - names - 2) << " = " << arg1 << endl;
printDebug(end, args...);
}
const int MAX_N = 1e5 + 10;
int arr[MAX_N];
int n, q;
signed main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cin >> n >> q;
for(int i = 0; i < n; i ++) {
cin >> arr[i];
}
while(q --) {
int now;
int cnt = 0;
cin >> now;
while(now) {
int best = 0;
for(int i = 0; i < n; i ++) {
chkmax(best, now % arr[i]);
}
if(best == 0) {
cout << "oo" << endl;
break;
}
now -= best;
cnt ++;
}
if(!now) {
cout << cnt << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
9 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
5 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
7 ms |
320 KB |
Output is correct |
11 |
Correct |
12 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
7 ms |
332 KB |
Output is correct |
14 |
Correct |
51 ms |
372 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
2 ms |
204 KB |
Output is correct |
17 |
Correct |
36 ms |
372 KB |
Output is correct |
18 |
Correct |
10 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
12 ms |
1332 KB |
Output is correct |
3 |
Correct |
9 ms |
992 KB |
Output is correct |
4 |
Correct |
3 ms |
332 KB |
Output is correct |
5 |
Correct |
7 ms |
844 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
3 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
9 ms |
980 KB |
Output is correct |
10 |
Correct |
9 ms |
972 KB |
Output is correct |
11 |
Correct |
9 ms |
716 KB |
Output is correct |
12 |
Correct |
3 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
6 ms |
716 KB |
Output is correct |
16 |
Correct |
12 ms |
1356 KB |
Output is correct |
17 |
Correct |
7 ms |
332 KB |
Output is correct |
18 |
Correct |
14 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1088 ms |
972 KB |
Time limit exceeded |
2 |
Execution timed out |
1096 ms |
972 KB |
Time limit exceeded |
3 |
Execution timed out |
1058 ms |
972 KB |
Time limit exceeded |
4 |
Execution timed out |
1090 ms |
424 KB |
Time limit exceeded |
5 |
Execution timed out |
1093 ms |
1612 KB |
Time limit exceeded |
6 |
Execution timed out |
1090 ms |
588 KB |
Time limit exceeded |
7 |
Execution timed out |
1083 ms |
1484 KB |
Time limit exceeded |
8 |
Execution timed out |
1088 ms |
972 KB |
Time limit exceeded |
9 |
Execution timed out |
1082 ms |
972 KB |
Time limit exceeded |
10 |
Execution timed out |
1086 ms |
332 KB |
Time limit exceeded |
11 |
Execution timed out |
1092 ms |
440 KB |
Time limit exceeded |
12 |
Execution timed out |
1088 ms |
332 KB |
Time limit exceeded |
13 |
Execution timed out |
1084 ms |
716 KB |
Time limit exceeded |
14 |
Execution timed out |
1090 ms |
332 KB |
Time limit exceeded |
15 |
Execution timed out |
1085 ms |
332 KB |
Time limit exceeded |
16 |
Execution timed out |
1085 ms |
460 KB |
Time limit exceeded |
17 |
Execution timed out |
1080 ms |
844 KB |
Time limit exceeded |
18 |
Execution timed out |
1075 ms |
972 KB |
Time limit exceeded |
19 |
Execution timed out |
1084 ms |
524 KB |
Time limit exceeded |
20 |
Execution timed out |
1088 ms |
972 KB |
Time limit exceeded |
21 |
Execution timed out |
1091 ms |
332 KB |
Time limit exceeded |
22 |
Execution timed out |
1087 ms |
1484 KB |
Time limit exceeded |
23 |
Execution timed out |
1086 ms |
716 KB |
Time limit exceeded |
24 |
Execution timed out |
1080 ms |
424 KB |
Time limit exceeded |
25 |
Execution timed out |
1098 ms |
332 KB |
Time limit exceeded |
26 |
Execution timed out |
1097 ms |
452 KB |
Time limit exceeded |
27 |
Execution timed out |
1081 ms |
1484 KB |
Time limit exceeded |
28 |
Execution timed out |
1084 ms |
412 KB |
Time limit exceeded |
29 |
Execution timed out |
1091 ms |
1484 KB |
Time limit exceeded |
30 |
Execution timed out |
1088 ms |
1100 KB |
Time limit exceeded |
31 |
Execution timed out |
1073 ms |
432 KB |
Time limit exceeded |
32 |
Execution timed out |
1080 ms |
424 KB |
Time limit exceeded |
33 |
Execution timed out |
1098 ms |
424 KB |
Time limit exceeded |
34 |
Execution timed out |
1065 ms |
1484 KB |
Time limit exceeded |
35 |
Execution timed out |
1093 ms |
332 KB |
Time limit exceeded |
36 |
Execution timed out |
1084 ms |
1484 KB |
Time limit exceeded |
37 |
Execution timed out |
1095 ms |
1612 KB |
Time limit exceeded |
38 |
Execution timed out |
1095 ms |
588 KB |
Time limit exceeded |
39 |
Execution timed out |
1089 ms |
420 KB |
Time limit exceeded |
40 |
Execution timed out |
1083 ms |
588 KB |
Time limit exceeded |
41 |
Execution timed out |
1069 ms |
1700 KB |
Time limit exceeded |
42 |
Execution timed out |
1095 ms |
332 KB |
Time limit exceeded |