#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<pii> 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].se+1, range[i-1].se+cnt};
}
cin >> q;
for(int i = 1; i <= q; i++) {
int x; cin >> x;
int l = 1, r = n, ret = 0;
while(l <= r) {
int mid = (l+r)/2;
auto [left, right] = range[mid];
if(x >= left && x <= right) {
ret = mid;
break;
}
if(x < left) r = mid-1;
else if(x > right) l = mid+1;
}
cout << arr[ret] << endl;
}
}
# |
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 |
Correct |
54 ms |
4896 KB |
Output is correct |
4 |
Correct |
170 ms |
1664 KB |
Output is correct |
5 |
Correct |
234 ms |
5304 KB |
Output is correct |
6 |
Correct |
122 ms |
4316 KB |
Output is correct |
7 |
Correct |
237 ms |
5344 KB |
Output is correct |
8 |
Correct |
237 ms |
5352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
54 ms |
4896 KB |
Output is correct |
4 |
Correct |
170 ms |
1664 KB |
Output is correct |
5 |
Correct |
234 ms |
5304 KB |
Output is correct |
6 |
Correct |
122 ms |
4316 KB |
Output is correct |
7 |
Correct |
237 ms |
5344 KB |
Output is correct |
8 |
Correct |
237 ms |
5352 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |