#include <bits/stdc++.h>
using namespace std;
const int MN = 200001;
int n, q, A[MN], S[MN];
int main() {
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> A[i];
S[i] = 1;
while(!(A[i] & 1)) {
A[i] >>= 1;
S[i] <<= 1;
}
S[i] += S[i - 1];
}
cin >> q;
for(int i = 1; i <= q; ++i) {
int p;
cin >> p;
int st = 1, dr = n, mij;
while(st < dr) {
mij = (st + dr) / 2;
if(S[mij] < p) st = mij + 1;
else dr = mij;
}
cout << A[st] << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
71 ms |
2500 KB |
Output is correct |
4 |
Correct |
212 ms |
1984 KB |
Output is correct |
5 |
Correct |
295 ms |
3972 KB |
Output is correct |
6 |
Correct |
143 ms |
2744 KB |
Output is correct |
7 |
Correct |
289 ms |
3980 KB |
Output is correct |
8 |
Correct |
285 ms |
4052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
71 ms |
2500 KB |
Output is correct |
4 |
Correct |
212 ms |
1984 KB |
Output is correct |
5 |
Correct |
295 ms |
3972 KB |
Output is correct |
6 |
Correct |
143 ms |
2744 KB |
Output is correct |
7 |
Correct |
289 ms |
3980 KB |
Output is correct |
8 |
Correct |
285 ms |
4052 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
308 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |