#include <bits/stdc++.h>
using namespace std;
int N, Q;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N;
vector<long long> A(N+1);
for (int i = 1; i <= N; i++) {
cin >> A[i];
}
vector<long long> amt(N+1), val(N+1);
for (int i = 1; i <= N; i++) {
long long div = 1;
while (A[i] % (2*div) == 0) {
div *= 2;
}
amt[i] = div;
val[i] = A[i]/div;
//cout << amt[i] << " " << A[i]/div << "\n";
}
cin >> Q;
int i = 1;
long long seen = 0;
while (Q--) {
long long X;
cin >> X;
while (X > seen+amt[i]) {
seen += amt[i];
i++;
}
cout << val[i] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
20 ms |
5456 KB |
Output is correct |
4 |
Correct |
25 ms |
2736 KB |
Output is correct |
5 |
Correct |
44 ms |
7116 KB |
Output is correct |
6 |
Correct |
27 ms |
5324 KB |
Output is correct |
7 |
Correct |
42 ms |
7064 KB |
Output is correct |
8 |
Correct |
47 ms |
7124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
352 KB |
Output is correct |
12 |
Correct |
1 ms |
356 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
20 ms |
5456 KB |
Output is correct |
4 |
Correct |
25 ms |
2736 KB |
Output is correct |
5 |
Correct |
44 ms |
7116 KB |
Output is correct |
6 |
Correct |
27 ms |
5324 KB |
Output is correct |
7 |
Correct |
42 ms |
7064 KB |
Output is correct |
8 |
Correct |
47 ms |
7124 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
316 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
320 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
352 KB |
Output is correct |
20 |
Correct |
1 ms |
356 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
352 KB |
Output is correct |
23 |
Correct |
23 ms |
3204 KB |
Output is correct |
24 |
Correct |
32 ms |
6452 KB |
Output is correct |
25 |
Correct |
60 ms |
10356 KB |
Output is correct |
26 |
Correct |
53 ms |
6504 KB |
Output is correct |
27 |
Correct |
52 ms |
6804 KB |
Output is correct |
28 |
Correct |
88 ms |
10768 KB |
Output is correct |
29 |
Correct |
108 ms |
10188 KB |
Output is correct |
30 |
Correct |
38 ms |
3888 KB |
Output is correct |
31 |
Correct |
95 ms |
10640 KB |
Output is correct |