#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
auto solve = [&]() {
int n;
cin >> n;
vector<int> a(n), b(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
b[i] = a[i] & -a[i];
}
int q;
cin >> q;
int i = 0;
i64 s = 0;
while (q--) {
i64 x;
cin >> x;
while (s + b[i] < x) {
s += b[i++];
}
cout << a[i] / b[i] << '\n';
}
};
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
16 ms |
2488 KB |
Output is correct |
4 |
Correct |
25 ms |
1884 KB |
Output is correct |
5 |
Correct |
42 ms |
3928 KB |
Output is correct |
6 |
Correct |
23 ms |
2784 KB |
Output is correct |
7 |
Correct |
39 ms |
4012 KB |
Output is correct |
8 |
Correct |
41 ms |
4044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
16 ms |
2488 KB |
Output is correct |
4 |
Correct |
25 ms |
1884 KB |
Output is correct |
5 |
Correct |
42 ms |
3928 KB |
Output is correct |
6 |
Correct |
23 ms |
2784 KB |
Output is correct |
7 |
Correct |
39 ms |
4012 KB |
Output is correct |
8 |
Correct |
41 ms |
4044 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
324 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
24 ms |
2712 KB |
Output is correct |
24 |
Correct |
29 ms |
4044 KB |
Output is correct |
25 |
Correct |
56 ms |
7256 KB |
Output is correct |
26 |
Correct |
38 ms |
4512 KB |
Output is correct |
27 |
Correct |
34 ms |
4380 KB |
Output is correct |
28 |
Correct |
67 ms |
7688 KB |
Output is correct |
29 |
Correct |
60 ms |
7136 KB |
Output is correct |
30 |
Correct |
48 ms |
3528 KB |
Output is correct |
31 |
Correct |
63 ms |
7516 KB |
Output is correct |