#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;
while(l <= r) {
int mid = (l+r)/2;
auto [left, right] = range[mid];
if(x >= left && x <= right) {
cout << arr[mid] << endl;
break;
}
if(x < left) r = mid-1;
else if(x > right) l = mid+1;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
65 ms |
4892 KB |
Output is correct |
4 |
Correct |
169 ms |
1632 KB |
Output is correct |
5 |
Correct |
231 ms |
5348 KB |
Output is correct |
6 |
Correct |
121 ms |
4548 KB |
Output is correct |
7 |
Correct |
238 ms |
5352 KB |
Output is correct |
8 |
Correct |
232 ms |
5384 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 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
65 ms |
4892 KB |
Output is correct |
4 |
Correct |
169 ms |
1632 KB |
Output is correct |
5 |
Correct |
231 ms |
5348 KB |
Output is correct |
6 |
Correct |
121 ms |
4548 KB |
Output is correct |
7 |
Correct |
238 ms |
5352 KB |
Output is correct |
8 |
Correct |
232 ms |
5384 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |