/** MIT License Copyright (c) 2018 Vasilyev Daniil **/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#pragma GCC optimize("Ofast")
template<typename T> using v = vector<T>;
template<typename T, typename U> using hmap = __gnu_pbds::gp_hash_table<T, U>;
//#define int long long
typedef long double ld;
typedef string str;
typedef vector<int> vint;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
#define pb push_back
#define fs first
#define sc second
#define sz(a) ((int) a.size())
const long long inf = 4611686018427387903; //2^62 - 1
#if 0 //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt" : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin>>
#define put fout<<
#else
#define get cin>>
#define put cout<<
#endif
#define eol put endl
#define check(a) put #a << ": " << a << endl;
void read() {} template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg) ;read(args...) ;}
void print(){} template<typename Arg,typename... Args> void print(Arg arg,Args... args){put (arg)<<" ";print(args...);}
void debug(){eol;} template<typename Arg,typename... Args> void debug(Arg arg,Args... args){put (arg)<<" ";debug(args...);}
int getInt(){int a; get a; return a;}
//code goes here
const long long N = 1e7 + 1;
const int LIM = 20;
int dp[N];
void run() {
int m, q;
read(m, q);
int p[m];
rep(i, 0, m)
get p[i];
long long mul = 1;
rep(i, 0, m) {
mul *= p[i];
if (mul > N) {
mul = 1e9;
break;
}
}
vint order;
int n = 0;
while (n <= min(N, mul)) {
order.pb(n);
int d = 0;
for (int i : p)
d = max(d, n / i * i + i);
n = d;
}
rep(i, 0, q) {
int n;
get n;
if (n >= mul)
put "oo";
else
put lower_bound(order.begin(), order.end(), n) - order.begin();
eol;
}
}
int32_t main() {srand(time(0)); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); put fixed; put setprecision(15); run(); return 0;}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
2 |
Incorrect |
6 ms |
640 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
16 ms |
512 KB |
Output isn't correct |
5 |
Incorrect |
8 ms |
1024 KB |
Output isn't correct |
6 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
9 |
Incorrect |
8 ms |
1532 KB |
Output isn't correct |
10 |
Incorrect |
7 ms |
768 KB |
Output isn't correct |
11 |
Incorrect |
7 ms |
768 KB |
Output isn't correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
7 ms |
384 KB |
Output is correct |
14 |
Incorrect |
19 ms |
512 KB |
Output isn't correct |
15 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
16 |
Incorrect |
6 ms |
512 KB |
Output isn't correct |
17 |
Incorrect |
18 ms |
640 KB |
Output isn't correct |
18 |
Incorrect |
17 ms |
512 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
2 |
Incorrect |
12 ms |
1408 KB |
Output isn't correct |
3 |
Incorrect |
10 ms |
1024 KB |
Output isn't correct |
4 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
8 ms |
896 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
356 KB |
Output isn't correct |
7 |
Incorrect |
4 ms |
512 KB |
Output isn't correct |
8 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
9 |
Correct |
11 ms |
1152 KB |
Output is correct |
10 |
Incorrect |
11 ms |
1152 KB |
Output isn't correct |
11 |
Incorrect |
7 ms |
768 KB |
Output isn't correct |
12 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
15 |
Correct |
8 ms |
768 KB |
Output is correct |
16 |
Incorrect |
11 ms |
1408 KB |
Output isn't correct |
17 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
18 |
Incorrect |
12 ms |
1536 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
63 ms |
1272 KB |
Output isn't correct |
2 |
Incorrect |
43 ms |
1152 KB |
Output isn't correct |
3 |
Incorrect |
84 ms |
1400 KB |
Output isn't correct |
4 |
Incorrect |
133 ms |
1272 KB |
Output isn't correct |
5 |
Correct |
151 ms |
2524 KB |
Output is correct |
6 |
Incorrect |
137 ms |
1528 KB |
Output isn't correct |
7 |
Incorrect |
90 ms |
2172 KB |
Output isn't correct |
8 |
Incorrect |
64 ms |
1400 KB |
Output isn't correct |
9 |
Incorrect |
65 ms |
1272 KB |
Output isn't correct |
10 |
Incorrect |
21 ms |
512 KB |
Output isn't correct |
11 |
Incorrect |
35 ms |
656 KB |
Output isn't correct |
12 |
Incorrect |
35 ms |
640 KB |
Output isn't correct |
13 |
Incorrect |
142 ms |
1556 KB |
Output isn't correct |
14 |
Incorrect |
149 ms |
1976 KB |
Output isn't correct |
15 |
Incorrect |
43 ms |
640 KB |
Output isn't correct |
16 |
Incorrect |
36 ms |
640 KB |
Output isn't correct |
17 |
Incorrect |
26 ms |
1016 KB |
Output isn't correct |
18 |
Incorrect |
46 ms |
1152 KB |
Output isn't correct |
19 |
Incorrect |
33 ms |
640 KB |
Output isn't correct |
20 |
Incorrect |
87 ms |
1528 KB |
Output isn't correct |
21 |
Incorrect |
145 ms |
1656 KB |
Output isn't correct |
22 |
Incorrect |
158 ms |
2588 KB |
Output isn't correct |
23 |
Incorrect |
154 ms |
1712 KB |
Output isn't correct |
24 |
Incorrect |
140 ms |
1512 KB |
Output isn't correct |
25 |
Incorrect |
146 ms |
1400 KB |
Output isn't correct |
26 |
Incorrect |
128 ms |
1244 KB |
Output isn't correct |
27 |
Incorrect |
90 ms |
2064 KB |
Output isn't correct |
28 |
Incorrect |
149 ms |
1544 KB |
Output isn't correct |
29 |
Incorrect |
157 ms |
2424 KB |
Output isn't correct |
30 |
Incorrect |
156 ms |
2168 KB |
Output isn't correct |
31 |
Incorrect |
126 ms |
1320 KB |
Output isn't correct |
32 |
Incorrect |
140 ms |
1400 KB |
Output isn't correct |
33 |
Incorrect |
134 ms |
1272 KB |
Output isn't correct |
34 |
Incorrect |
89 ms |
2092 KB |
Output isn't correct |
35 |
Incorrect |
145 ms |
1400 KB |
Output isn't correct |
36 |
Incorrect |
153 ms |
2396 KB |
Output isn't correct |
37 |
Correct |
151 ms |
2496 KB |
Output is correct |
38 |
Incorrect |
136 ms |
1400 KB |
Output isn't correct |
39 |
Incorrect |
147 ms |
1540 KB |
Output isn't correct |
40 |
Incorrect |
135 ms |
1532 KB |
Output isn't correct |
41 |
Correct |
89 ms |
2040 KB |
Output is correct |
42 |
Incorrect |
146 ms |
1692 KB |
Output isn't correct |