#include<bits/stdc++.h>
using namespace std;
#define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define tup tuple<int, int, int>
#define pii pair<int, int>
#define fi first
#define se second
#define pub push_back
#define pob pop_back
int n, arr[200004], q;
signed main() {
ioss;
cin >> n;
vector<int> range(n+2);
for(int i = 1; i <= n; i++) {
cin >> arr[i];
int cnt = 0;
for(int j = 0; j < 30; j++) {
if(arr[i]%(1ll << j) == 0) cnt = (1ll << j);
else {
arr[i] = arr[i]/(1ll << (j-1));
break;
}
}
range[i] = range[i-1]+cnt;
}
cin >> q;
int idx = 1;
for(int i = 1; i <= q; i++) {
int x; cin >> x;
while(range[idx] < x) idx++;
cout << arr[idx] << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
52 ms |
3316 KB |
Output is correct |
4 |
Correct |
164 ms |
1292 KB |
Output is correct |
5 |
Correct |
244 ms |
3828 KB |
Output is correct |
6 |
Correct |
131 ms |
3112 KB |
Output is correct |
7 |
Correct |
227 ms |
3788 KB |
Output is correct |
8 |
Correct |
231 ms |
3800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
52 ms |
3316 KB |
Output is correct |
4 |
Correct |
164 ms |
1292 KB |
Output is correct |
5 |
Correct |
244 ms |
3828 KB |
Output is correct |
6 |
Correct |
131 ms |
3112 KB |
Output is correct |
7 |
Correct |
227 ms |
3788 KB |
Output is correct |
8 |
Correct |
231 ms |
3800 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |